pub fn verifier_from_pem(
        &self,
        input: impl AsRef<[u8]>,
    ) -> Result<EcdsaJwsVerifier, JoseError> {
        (|| -> anyhow::Result<EcdsaJwsVerifier> {
            let (alg, data) = util::parse_pem(input.as_ref())?;

            let spki = match alg.as_str() {
                "PUBLIC KEY" => {
                    if let None = EcKeyPair::detect_pkcs8(&data, true) {
                        bail!("PEM contents is expected SubjectPublicKeyInfo wrapped key.");
                    }
                    &data
                }
                alg => bail!("Inappropriate algorithm: {}", alg),
            };

            let public_key = PKey::public_key_from_der(spki)?;

            Ok(EcdsaJwsVerifier {
                algorithm: self.clone(),
                public_key,
                key_id: None,
            })
        })()
        .map_err(|err| JoseError::InvalidKeyFormat(err))
    }
/// Return a verifier from a key of common PEM format.
///
/// Common PEM format is a DER and base64 encoded SubjectPublicKeyInfo
/// that surrounded by "-----BEGIN/END PUBLIC KEY----".
///
/// # Arguments
/// * `input` - A public key of common or traditional PEM format.
Return a verifier from a key of common PEM format.
Common PEM format is a DER and base64 encoded SubjectPublicKeyInfo
that surrounded by "BEGIN/END PUBLIC KEY----".
Return a verifier from a key of common PEM format . Common PEM format is a DER and base64 encoded SubjectPublicKeyInfo that surrounded by " BEGIN / END PUBLIC KEY ---- " .
pub fn verifier_from_pem(
        &self,
        input: impl AsRef<[u8]>,
    ) -> Result<EcdsaJwsVerifier, JoseError> {
        (|| -> anyhow::Result<EcdsaJwsVerifier> {
            let (alg, data) = util::parse_pem(input.as_ref())?;
            let spki = match alg.as_str() {
                "PUBLIC KEY" => {
                    if let None = EcKeyPair::detect_pkcs8(&data, true) {
                        bail!("PEM contents is expected SubjectPublicKeyInfo wrapped key.");
                    }
                    &data
                }
                alg => bail!("Inappropriate algorithm: {}", alg),
            };
            let public_key = PKey::public_key_from_der(spki)?;
            Ok(EcdsaJwsVerifier {
                algorithm: self.clone(),
                public_key,
                key_id: None,
            })
        })()
        .map_err(|err| JoseError::InvalidKeyFormat(err))
    }
pub fn verifier_from_pem ( & self , input : impl AsRef < [ u8 ] > , ) -> Result < EcdsaJwsVerifier , JoseError > { ( | | -> anyhow :: Result < EcdsaJwsVerifier > { let ( alg , data ) = util :: parse_pem ( input . as_ref ( ) ) ? ; let spki = match alg . as_str ( ) { " " => { if let None = EcKeyPair :: detect_pkcs8 ( & data , true ) { bail ! ( " " ) ; } & data } alg => bail ! ( " " alg ) , } ; let public_key = PKey :: public_key_from_der ( spki ) ? ; Ok ( EcdsaJwsVerifier { algorithm : self . clone ( ) , public_key , key_id : None , } ) } ) ( ) . map_err ( | err | JoseError :: InvalidKeyFormat ( err ) ) }
Return a verifier from a key of common PEM format.
Return a verifier from a key of common PEM format .
&self
input
impl AsRef<[u8]>
&self
input
impl AsRef<[u8]>