pub fn create_certificates(shared_settings: &Shared) -> Result<(), Error> {
    let certs_dir = shared_settings.pueue_directory.join("certs");

    let daemon_cert_path = certs_dir.join("daemon.cert");
    let daemon_key_path = certs_dir.join("daemon.key");

    if daemon_key_path.exists() || daemon_cert_path.exists() {
        if !(daemon_key_path.exists() && daemon_cert_path.exists()) {
            return Err(Error::CertificateFailure(
                "Not all default certificates exist, some are missing. \
                 Please fix your cert/key paths.\n \
                 You can also remove the `$pueue_directory/certs` directory \
                 and restart the daemon to create new certificates/keys."
                    .into(),
            ));
        }
        info!("All default keys do exist.");
        return Ok(());
    }

    let subject_alt_names = vec!["pueue.local".to_string(), "localhost".to_string()];

    let cert = generate_simple_self_signed(subject_alt_names).unwrap();
    // The certificate is now valid for localhost and the domain "hello.world.example"
    let ca_cert = cert
        .serialize_pem()
        .map_err(|_| Error::CertificateFailure("Failed to serialize daemon certificate.".into()))?;
    write_file(ca_cert, "daemon cert", &daemon_cert_path)?;

    let ca_key = cert.serialize_private_key_pem();
    write_file(ca_key, "daemon key", &daemon_key_path)?;

    Ok(())
}
/// This the default certificates at the default `pueue_dir/certs` location.
This the default certificates at the default `pueue_dir/certs` location.
This the default certificates at the default ` pueue_dir / certs ` location .
pub fn create_certificates(shared_settings: &Shared) -> Result<(), Error> {
    let certs_dir = shared_settings.pueue_directory.join("certs");
    let daemon_cert_path = certs_dir.join("daemon.cert");
    let daemon_key_path = certs_dir.join("daemon.key");
    if daemon_key_path.exists() || daemon_cert_path.exists() {
        if !(daemon_key_path.exists() && daemon_cert_path.exists()) {
            return Err(Error::CertificateFailure(
                "Not all default certificates exist, some are missing. \
                 Please fix your cert/key paths.\n \
                 You can also remove the `$pueue_directory/certs` directory \
                 and restart the daemon to create new certificates/keys."
                    .into(),
            ));
        }
        info!("All default keys do exist.");
        return Ok(());
    }
    let subject_alt_names = vec!["pueue.local".to_string(), "localhost".to_string()];
    let cert = generate_simple_self_signed(subject_alt_names).unwrap();
    // The certificate is now valid for localhost and the domain "hello.world.example"
    let ca_cert = cert
        .serialize_pem()
        .map_err(|_| Error::CertificateFailure("Failed to serialize daemon certificate.".into()))?;
    write_file(ca_cert, "daemon cert", &daemon_cert_path)?;
    let ca_key = cert.serialize_private_key_pem();
    write_file(ca_key, "daemon key", &daemon_key_path)?;
    Ok(())
}
pub fn create_certificates ( shared_settings : & Shared ) -> Result < ( ) , Error > { let certs_dir = shared_settings . pueue_directory . join ( " " ) ; let daemon_cert_path = certs_dir . join ( " " ) ; let daemon_key_path = certs_dir . join ( " " ) ; if daemon_key_path . exists ( ) || daemon_cert_path . exists ( ) { if ! ( daemon_key_path . exists ( ) && daemon_cert_path . exists ( ) ) { return Err ( Error :: CertificateFailure ( " \
 \n \
 \
 " . into ( ) , ) ) ; } info ! ( " " ) ; return Ok ( ( ) ) ; } let subject_alt_names = vec ! [ " " to_string ( ) " " to_string ( ) ] ; let cert = generate_simple_self_signed ( subject_alt_names ) . unwrap ( ) ; // The certificate is now valid for localhost and the domain "hello.world.example" let ca_cert = cert . serialize_pem ( ) . map_err ( | _ | Error :: CertificateFailure ( " " . into ( ) ) ) ? ; write_file ( ca_cert , " " , & daemon_cert_path ) ? ; let ca_key = cert . serialize_private_key_pem ( ) ; write_file ( ca_key , " " , & daemon_key_path ) ? ; Ok ( ( ) ) }
This the default certificates at the default `pueue_dir/certs` location.
This the default certificates at the default ` pueue_dir / certs ` location .
shared_settings
&Shared
shared_settings
&Shared