async fn certify<C, S>(token: &TokenSource, client: S, credentials: &mut C) -> Result<SystemTime>
where
    C: Credentials,
    S: GrpcService<BoxBody>,
    S::ResponseBody: Default + Body<Data = tonic::codegen::Bytes> + Send + 'static,
    <S::ResponseBody as Body>::Error: Into<Error> + Send,
{
    let req = tonic::Request::new(api::CertifyRequest {
        token: token.load()?,
        identity: credentials.dns_name().to_string(),
        certificate_signing_request: credentials.gen_certificate_signing_request().to_vec(),
    });

    let api::CertifyResponse {
        leaf_certificate,
        intermediate_certificates,
        valid_until,
    } = IdentityClient::new(client).certify(req).await?.into_inner();

    let exp = valid_until.ok_or("identity certification missing expiration")?;
    let expiry = SystemTime::try_from(exp)?;
    if expiry <= SystemTime::now() {
        return Err("certificate already expired".into());
    }
    credentials.set_certificate(
        DerX509(leaf_certificate),
        intermediate_certificates.into_iter().map(DerX509).collect(),
        expiry,
    )?;

    Ok(expiry)
}
/// Issues a certificate signing request to the identity service with a token loaded from the token
/// source.
Issues a certificate signing request to the identity service with a token loaded from the token
source.
Issues a certificate signing request to the identity service with a token loaded from the token source .
async fn certify<C, S>(token: &TokenSource, client: S, credentials: &mut C) -> Result<SystemTime>
where
    C: Credentials,
    S: GrpcService<BoxBody>,
    S::ResponseBody: Default + Body<Data = tonic::codegen::Bytes> + Send + 'static,
    <S::ResponseBody as Body>::Error: Into<Error> + Send,
{
    let req = tonic::Request::new(api::CertifyRequest {
        token: token.load()?,
        identity: credentials.dns_name().to_string(),
        certificate_signing_request: credentials.gen_certificate_signing_request().to_vec(),
    });
    let api::CertifyResponse {
        leaf_certificate,
        intermediate_certificates,
        valid_until,
    } = IdentityClient::new(client).certify(req).await?.into_inner();
    let exp = valid_until.ok_or("identity certification missing expiration")?;
    let expiry = SystemTime::try_from(exp)?;
    if expiry <= SystemTime::now() {
        return Err("certificate already expired".into());
    }
    credentials.set_certificate(
        DerX509(leaf_certificate),
        intermediate_certificates.into_iter().map(DerX509).collect(),
        expiry,
    )?;
    Ok(expiry)
}
async fn certify < C , S > ( token : & TokenSource , client : S , credentials : & mut C ) -> Result < SystemTime > where C : Credentials , S : GrpcService < BoxBody > , S :: ResponseBody : Default + Body < Data = tonic :: codegen :: Bytes > + Send + ' static , < S :: ResponseBody as Body > :: Error : Into < Error > + Send , { let req = tonic :: Request :: new ( api :: CertifyRequest { token : token . load ( ) ? , identity : credentials . dns_name ( ) . to_string ( ) , certificate_signing_request : credentials . gen_certificate_signing_request ( ) . to_vec ( ) , } ) ; let api :: CertifyResponse { leaf_certificate , intermediate_certificates , valid_until , } = IdentityClient :: new ( client ) . certify ( req ) . await ? . into_inner ( ) ; let exp = valid_until . ok_or ( " " ) ? ; let expiry = SystemTime :: try_from ( exp ) ? ; if expiry <= SystemTime :: now ( ) { return Err ( " " . into ( ) ) ; } credentials . set_certificate ( DerX509 ( leaf_certificate ) , intermediate_certificates . into_iter ( ) . map ( DerX509 ) . collect ( ) , expiry , ) ? ; Ok ( expiry ) }
Issues a certificate signing request to the identity service with a token loaded from the token
source.
Issues a certificate signing request to the identity service with a token loaded from the token source .
token
&TokenSource
client
S
credentials
&mut C