pub fn init_cert_from_base64(buf: &str) -> Result<X509, CertParseError> {
    let buf = buf.replace("\n", "").replace(" ", "");

    // let mut buf = Vec::new();
    // File::open("my_cert.der")?
    //     .read_to_end(&mut buf)?;

    let decoded = base64::decode(buf);

    match decoded {
        Err(error) => {
            eprintln!("base64 decode error: {:?}", error);
            Err(CertParseError)
        }
        Ok(value) => match X509::from_der(&value) {
            Ok(value) => Ok(value),
            Err(error) => {
                eprintln!("Error parsing DER cert: {:?}", error);
                Err(CertParseError)
            }
        },
    }
}
/// this is a terrible function and only used for me to figure out how to parse out the cert from an SP Metadata file
this is a terrible function and only used for me to figure out how to parse out the cert from an SP Metadata file
this is a terrible function and only used for me to figure out how to parse out the cert from an SP Metadata file
pub fn init_cert_from_base64(buf: &str) -> Result<X509, CertParseError> {
    let buf = buf.replace("\n", "").replace(" ", "");
    // let mut buf = Vec::new();
    // File::open("my_cert.der")?
    //     .read_to_end(&mut buf)?;
    let decoded = base64::decode(buf);
    match decoded {
        Err(error) => {
            eprintln!("base64 decode error: {:?}", error);
            Err(CertParseError)
        }
        Ok(value) => match X509::from_der(&value) {
            Ok(value) => Ok(value),
            Err(error) => {
                eprintln!("Error parsing DER cert: {:?}", error);
                Err(CertParseError)
            }
        },
    }
}
pub fn init_cert_from_base64 ( buf : & str ) -> Result < X509 , CertParseError > { let buf = buf . replace ( " \n " , " " ) . replace ( " " , " " ) ; // let mut buf = Vec::new(); // File::open("my_cert.der")? //     .read_to_end(&mut buf)?; let decoded = base64 :: decode ( buf ) ; match decoded { Err ( error ) => { eprintln ! ( " " error ) ; Err ( CertParseError ) } Ok ( value ) => match X509 :: from_der ( & value ) { Ok ( value ) => Ok ( value ) , Err ( error ) => { eprintln ! ( " " error ) ; Err ( CertParseError ) } } , } }
this is a terrible function and only used for me to figure out how to parse out the cert from an SP Metadata file
this is a terrible function and only used for me to figure out how to parse out the cert from an SP Metadata file
buf
&str
buf
&str