/// Installs an X.509 certificate used for general purpose connections.
Installs an X.509 certificate used for general purpose connections.
Installs an X . 509 certificate used for general purpose connections .
pub async fn install_self_signed_certificate(&self, overwrite: bool) -> Result<(), Error> {
        let keypair = KeyPair::new_self_signed(&self.data.primary_domain);
        if self.certificate_chain().await.is_ok() && !overwrite {
            return Err(Error::Core(bonsaidb_core::Error::Configuration(String::from("Certificate already installed. Enable overwrite if you wish to replace the existing certificate."))));
        }
        self.install_certificate(keypair.certificate_chain(), keypair.private_key())
            .await?;
        tokio::fs::write(
            self.pinned_certificate_path(),
            keypair.end_entity_certificate().as_ref(),
        )
        .await?;
        Ok(())
    }
pub async fn install_self_signed_certificate ( & self , overwrite : bool ) -> Result < ( ) , Error > { let keypair = KeyPair :: new_self_signed ( & self . data . primary_domain ) ; if self . certificate_chain ( ) . await . is_ok ( ) && ! overwrite { return Err ( Error :: Core ( bonsaidb_core :: Error :: Configuration ( String :: from ( " " ) ) ) ) ; } self . install_certificate ( keypair . certificate_chain ( ) , keypair . private_key ( ) ) . await ? ; tokio :: fs :: write ( self . pinned_certificate_path ( ) , keypair . end_entity_certificate ( ) . as_ref ( ) , ) . await ? ; Ok ( ( ) ) }
Installs an X.509 certificate used for general purpose connections.
Installs an X . 509 certificate used for general purpose connections .
&self
overwrite
bool