Function xstack_x509::verify
source ยท pub fn verify<D: AsRef<[u8]>>(der: D) -> Result<PublicKey>Expand description
Parse and verify the libp2p certificate from ASN.1 DER format.
On success, returns the PeerId extract from
libp2p public key extension.
Codes below shows how to verify libp2p certificate using boring crate:
// config.set_custom_verify_callback(SslVerifyMode::PEER, |ssl| {
// let cert = ssl
// .peer_certificate()
// .ok_or(SslVerifyError::Invalid(SslAlert::CERTIFICATE_REQUIRED))?;
//
// let cert = cert.to_der().map_err(|err| {
// log::error!("{}", err);
// SslVerifyError::Invalid(SslAlert::BAD_CERTIFICATE)
// })?;
//
// let peer_id = xstack_x509::verify(cert)
// .map_err(|err| {
// log::error!("{}", err);
// SslVerifyError::Invalid(SslAlert::BAD_CERTIFICATE)
// })?
// .to_peer_id();
//
// log::trace!("ssl_client: verified peer={}", peer_id);
//
// Ok(())
// });Refer to tls crate for complete code