pub struct ClientIdentity { /* private fields */ }client only.Expand description
The client certificate and key Hubject issued for this partner.
§OICP has no tokens
There is no API key, no OAuth, no bearer. Authentication is the TLS client certificate, and
authorisation is Hubject comparing the OperatorID/ProviderID in the URL path against that
certificate:
Hubject compares the given Provider- or OperatorID to the partner’s SSL client certificate information with every web service request. […] If Hubject detects a mismatch […] Hubject will not perform the operation and will respond with the status code 017 “Unauthorized Access”.
That failure arrives as a 017 on every request, with no indication of which of the two sides
is wrong. ClientIdentity::check_against does the comparison locally, at startup, and says
which — see IdentityWarning.
Implementations§
Source§impl ClientIdentity
impl ClientIdentity
Sourcepub fn from_pem(pem: impl Into<Vec<u8>>) -> Result<Self, OicpError>
pub fn from_pem(pem: impl Into<Vec<u8>>) -> Result<Self, OicpError>
Loads a certificate chain and private key from one PEM buffer.
§Errors
Returns OicpError::Transport when the buffer holds no certificate, or no private key.
Sourcepub fn from_pem_file(path: impl AsRef<Path>) -> Result<Self, OicpError>
pub fn from_pem_file(path: impl AsRef<Path>) -> Result<Self, OicpError>
Loads a certificate and key from a PEM file.
§Errors
Returns OicpError::Transport when the file cannot be read or does not hold both parts.
Sourcepub fn subject_alternative_names(&self) -> &[String]
pub fn subject_alternative_names(&self) -> &[String]
The subject alternative names, as far as they could be read.
Sourcepub fn check_against(&self, id: &str) -> Option<IdentityWarning>
pub fn check_against(&self, id: &str) -> Option<IdentityWarning>
Checks that id appears somewhere in the certificate’s names.
Returns None when it does, or when the certificate’s names could not be read at all —
this is a helpful local check, not a security boundary, and refusing to start because a
certificate encoding was unfamiliar would be worse than useless.