pub fn request_cert<I>(&self, name: &str, ips: I) -> Result<(PathBuf, PathBuf), Box<dyn Error>>
    where
        I: IntoIterator<Item = IpAddr>,
    {
        let rsa = Rsa::generate(2048)?;
        let pkey = PKey::from_rsa(rsa)?;
        let subject_name = {
            let mut builder = X509NameBuilder::new()?;
            builder.append_entry_by_nid(Nid::COMMONNAME, name)?;
            builder.build()
        };
        let cert = {
            let mut builder = X509::builder()?;
            builder.set_version(2)?;
            builder.set_pubkey(&pkey)?;
            builder.set_issuer_name(&self.cert.subject_name())?;
            builder.set_subject_name(&subject_name)?;
            builder.set_not_before(&*Asn1Time::days_from_now(0)?)?;
            builder.set_not_after(&*Asn1Time::days_from_now(365)?)?;
            for ip in ips {
                builder.append_extension(
                    SubjectAlternativeName::new()
                        .ip(&ip.to_string())
                        .build(&builder.x509v3_context(None, None))?,
                )?;
            }
            builder.sign(&self.pkey, MessageDigest::sha256())?;
            builder.build()
        };
        let cert_path = self.dir.path().join(Path::new(name).with_extension("crt"));
        let key_path = self.dir.path().join(Path::new(name).with_extension("key"));
        fs::write(&cert_path, &cert.to_pem()?)?;
        fs::write(&key_path, &pkey.private_key_to_pem_pkcs8()?)?;
        Ok((cert_path, key_path))
    }
/// Like `request_client_cert`, but permits specifying additional IP
/// addresses to attach as Subject Alternate Names.
Like `request_client_cert`, but permits specifying additional IP
addresses to attach as Subject Alternate Names.
Like ` request_client_cert ` but permits specifying additional IP addresses to attach as Subject Alternate Names .
pub fn request_cert<I>(&self, name: &str, ips: I) -> Result<(PathBuf, PathBuf), Box<dyn Error>>
    where
        I: IntoIterator<Item = IpAddr>,
    {
        let rsa = Rsa::generate(2048)?;
        let pkey = PKey::from_rsa(rsa)?;
        let subject_name = {
            let mut builder = X509NameBuilder::new()?;
            builder.append_entry_by_nid(Nid::COMMONNAME, name)?;
            builder.build()
        };
        let cert = {
            let mut builder = X509::builder()?;
            builder.set_version(2)?;
            builder.set_pubkey(&pkey)?;
            builder.set_issuer_name(&self.cert.subject_name())?;
            builder.set_subject_name(&subject_name)?;
            builder.set_not_before(&*Asn1Time::days_from_now(0)?)?;
            builder.set_not_after(&*Asn1Time::days_from_now(365)?)?;
            for ip in ips {
                builder.append_extension(
                    SubjectAlternativeName::new()
                        .ip(&ip.to_string())
                        .build(&builder.x509v3_context(None, None))?,
                )?;
            }
            builder.sign(&self.pkey, MessageDigest::sha256())?;
            builder.build()
        };
        let cert_path = self.dir.path().join(Path::new(name).with_extension("crt"));
        let key_path = self.dir.path().join(Path::new(name).with_extension("key"));
        fs::write(&cert_path, &cert.to_pem()?)?;
        fs::write(&key_path, &pkey.private_key_to_pem_pkcs8()?)?;
        Ok((cert_path, key_path))
    }
pub fn request_cert < I > ( & self , name : & str , ips : I ) -> Result < ( PathBuf , PathBuf ) , Box < dyn Error > > where I : IntoIterator < Item = IpAddr > , { let rsa = Rsa :: generate ( 2048 ) ? ; let pkey = PKey :: from_rsa ( rsa ) ? ; let subject_name = { let mut builder = X509NameBuilder :: new ( ) ? ; builder . append_entry_by_nid ( Nid :: COMMONNAME , name ) ? ; builder . build ( ) } ; let cert = { let mut builder = X509 :: builder ( ) ? ; builder . set_version ( 2 ) ? ; builder . set_pubkey ( & pkey ) ? ; builder . set_issuer_name ( & self . cert . subject_name ( ) ) ? ; builder . set_subject_name ( & subject_name ) ? ; builder . set_not_before ( & * Asn1Time :: days_from_now ( 0 ) ? ) ? ; builder . set_not_after ( & * Asn1Time :: days_from_now ( 365 ) ? ) ? ; for ip in ips { builder . append_extension ( SubjectAlternativeName :: new ( ) . ip ( & ip . to_string ( ) ) . build ( & builder . x509v3_context ( None , None ) ) ? , ) ? ; } builder . sign ( & self . pkey , MessageDigest :: sha256 ( ) ) ? ; builder . build ( ) } ; let cert_path = self . dir . path ( ) . join ( Path :: new ( name ) . with_extension ( " " ) ) ; let key_path = self . dir . path ( ) . join ( Path :: new ( name ) . with_extension ( " " ) ) ; fs :: write ( & cert_path , & cert . to_pem ( ) ? ) ? ; fs :: write ( & key_path , & pkey . private_key_to_pem_pkcs8 ( ) ? ) ? ; Ok ( ( cert_path , key_path ) ) }
Like `request_client_cert`, but permits specifying additional IP
addresses to attach as Subject Alternate Names.
Like ` request_client_cert ` but permits specifying additional IP addresses to attach as Subject Alternate Names .
&self
name
&str
ips
I
&self
name
&str
ips
I