pub fn sign(mut self, signer: impl FnOnce(&[u8]) -> Option<Vec<u8>>) -> Result<Self> {
        let mut writer = super::Writer::new();
        let kt_name = format!("{}-cert-v01@openssh.com", self.key.key_type.name);
        // Write the cert type
        writer.write_string(kt_name.as_str());

        // Write the nonce
        writer.write_bytes(&self.nonce);

        // Write the user public key
        writer.write_pub_key(&self.key);

        // Write the serial number
        writer.write_u64(self.serial);

        // Write what kind of cert this is
        writer.write_u32(self.cert_type as u32);

        // Write the key id
        writer.write_string(&self.key_id);

        // Write the principals
        writer.write_string_vec(&self.principals);

        // Write valid after
        writer.write_u64(self.valid_after);

        // Write valid before
        writer.write_u64(self.valid_before);

        // Write the critical options
        writer.write_string_map(&self.critical_options);

        // Write the extensions
        writer.write_string_map(&self.extensions);

        // Write the unused reserved bytes
        writer.write_u32(0x0);

        // Write the CA public key
        writer.write_bytes(&self.signature_key.encode());

        // Sign the data and write it to the cert
        let signature =  match signer(writer.as_bytes()) {
            Some(sig) => sig,
            None => return Err(Error::SigningError),
        };

        if let Err(e) = verify_signature(&signature, &writer.as_bytes(), &self.signature_key) {
            return Err(e)
        }

        writer.write_bytes(&signature);

        self.signature = signature;
        self.serialized = writer.into_bytes();
        Ok(self)
    }
/// Take the certificate settings and generate a valid signature using the provided signer function
Take the certificate settings and generate a valid signature using the provided signer function
Take the certificate settings and generate a valid signature using the provided signer function
pub fn sign(mut self, signer: impl FnOnce(&[u8]) -> Option<Vec<u8>>) -> Result<Self> {
        let mut writer = super::Writer::new();
        let kt_name = format!("{}-cert-v01@openssh.com", self.key.key_type.name);
        // Write the cert type
        writer.write_string(kt_name.as_str());
        // Write the nonce
        writer.write_bytes(&self.nonce);
        // Write the user public key
        writer.write_pub_key(&self.key);
        // Write the serial number
        writer.write_u64(self.serial);
        // Write what kind of cert this is
        writer.write_u32(self.cert_type as u32);
        // Write the key id
        writer.write_string(&self.key_id);
        // Write the principals
        writer.write_string_vec(&self.principals);
        // Write valid after
        writer.write_u64(self.valid_after);
        // Write valid before
        writer.write_u64(self.valid_before);
        // Write the critical options
        writer.write_string_map(&self.critical_options);
        // Write the extensions
        writer.write_string_map(&self.extensions);
        // Write the unused reserved bytes
        writer.write_u32(0x0);
        // Write the CA public key
        writer.write_bytes(&self.signature_key.encode());
        // Sign the data and write it to the cert
        let signature =  match signer(writer.as_bytes()) {
            Some(sig) => sig,
            None => return Err(Error::SigningError),
        };
        if let Err(e) = verify_signature(&signature, &writer.as_bytes(), &self.signature_key) {
            return Err(e)
        }
        writer.write_bytes(&signature);
        self.signature = signature;
        self.serialized = writer.into_bytes();
        Ok(self)
    }
pub fn sign ( mut self , signer : impl FnOnce ( & [ u8 ] ) -> Option < Vec < u8 > > ) -> Result < Self > { let mut writer = super :: Writer :: new ( ) ; let kt_name = format ! ( " " self key key_type name ) ; // Write the cert type writer . write_string ( kt_name . as_str ( ) ) ; // Write the nonce writer . write_bytes ( & self . nonce ) ; // Write the user public key writer . write_pub_key ( & self . key ) ; // Write the serial number writer . write_u64 ( self . serial ) ; // Write what kind of cert this is writer . write_u32 ( self . cert_type as u32 ) ; // Write the key id writer . write_string ( & self . key_id ) ; // Write the principals writer . write_string_vec ( & self . principals ) ; // Write valid after writer . write_u64 ( self . valid_after ) ; // Write valid before writer . write_u64 ( self . valid_before ) ; // Write the critical options writer . write_string_map ( & self . critical_options ) ; // Write the extensions writer . write_string_map ( & self . extensions ) ; // Write the unused reserved bytes writer . write_u32 ( 0x0 ) ; // Write the CA public key writer . write_bytes ( & self . signature_key . encode ( ) ) ; // Sign the data and write it to the cert let signature = match signer ( writer . as_bytes ( ) ) { Some ( sig ) => sig , None => return Err ( Error :: SigningError ) , } ; if let Err ( e ) = verify_signature ( & signature , & writer . as_bytes ( ) , & self . signature_key ) { return Err ( e ) } writer . write_bytes ( & signature ) ; self . signature = signature ; self . serialized = writer . into_bytes ( ) ; Ok ( self ) }
Take the certificate settings and generate a valid signature using the provided signer function
Take the certificate settings and generate a valid signature using the provided signer function
mut self
signer
impl FnOnce(&[u8]) -> Option<Vec<u8>>