pub fn load_public_cert_from_filename(cert_filename: &str) -> Result<X509, String> {
    log::debug!("loading cert:  {}", cert_filename);

    let mut f = match File::open(&cert_filename) {
        Ok(value) => value,
        Err(error) => {
            return Err(format!(
                "Error loading certificate file {}: {:?}",
                &cert_filename, error
            ))
        }
    };

    let mut cert_buffer = Vec::new();
    // read the whole file
    // TODO: handle file read errors, but if we've gotten here without bailing then well, how'd the server start up?
    match f.read_to_end(&mut cert_buffer) {
        Ok(_) => eprintln!("Read certificate OK"),
        Err(error) => {
            return Err(format!("Failed to read cert? {:?}", error));
        }
    }

    match X509::from_pem(&cert_buffer) {
        Ok(value) => Ok(value),
        Err(error) => Err(format!(
            "Failed to load certificate from pem bytes: {:?}",
            error
        )),
    }
}
/// Loads a public cert from a PEM file into an X509 object
Loads a public cert from a PEM file into an X509 object
Loads a public cert from a PEM file into an X509 object
pub fn load_public_cert_from_filename(cert_filename: &str) -> Result<X509, String> {
    log::debug!("loading cert:  {}", cert_filename);
    let mut f = match File::open(&cert_filename) {
        Ok(value) => value,
        Err(error) => {
            return Err(format!(
                "Error loading certificate file {}: {:?}",
                &cert_filename, error
            ))
        }
    };
    let mut cert_buffer = Vec::new();
    // read the whole file
    // TODO: handle file read errors, but if we've gotten here without bailing then well, how'd the server start up?
    match f.read_to_end(&mut cert_buffer) {
        Ok(_) => eprintln!("Read certificate OK"),
        Err(error) => {
            return Err(format!("Failed to read cert? {:?}", error));
        }
    }
    match X509::from_pem(&cert_buffer) {
        Ok(value) => Ok(value),
        Err(error) => Err(format!(
            "Failed to load certificate from pem bytes: {:?}",
            error
        )),
    }
}
pub fn load_public_cert_from_filename ( cert_filename : & str ) -> Result < X509 , String > { log :: debug ! ( " " cert_filename ) ; let mut f = match File :: open ( & cert_filename ) { Ok ( value ) => value , Err ( error ) => { return Err ( format ! ( " " cert_filename error ) ) } } ; let mut cert_buffer = Vec :: new ( ) ; // read the whole file // TODO: handle file read errors, but if we've gotten here without bailing then well, how'd the server start up? match f . read_to_end ( & mut cert_buffer ) { Ok ( _ ) => eprintln ! ( " " ) , Err ( error ) => { return Err ( format ! ( " " error ) ) ; } } match X509 :: from_pem ( & cert_buffer ) { Ok ( value ) => Ok ( value ) , Err ( error ) => Err ( format ! ( " " error ) ) , } }
Loads a public cert from a PEM file into an X509 object
Loads a public cert from a PEM file into an X509 object
cert_filename
&str
cert_filename
&str