@@ -7,7 +7,7 @@ use tokio::sync::mpsc;
77use tokio_rustls:: rustls:: {
88 crypto:: CryptoProvider , server:: ResolvesServerCert , sign:: CertifiedKey ,
99} ;
10- use x509_cert:: Certificate ;
10+ use x509_cert:: { Certificate , certificate :: CertificateInner } ;
1111
1212use super :: { WEBHOOK_CA_LIFETIME , WEBHOOK_CERTIFICATE_LIFETIME } ;
1313
@@ -78,10 +78,7 @@ impl CertificateResolver {
7878 . await
7979 . context ( GenerateNewCertificateSnafu ) ?;
8080
81- cert_tx
82- . send ( cert)
83- . await
84- . map_err ( |_err| CertificateResolverError :: SendCertificateToChannel ) ?;
81+ Self :: send_certificate_to_channel ( cert, & cert_tx) . await ?;
8582
8683 Ok ( Self {
8784 subject_alterative_dns_names,
@@ -98,11 +95,7 @@ impl CertificateResolver {
9895
9996 // TODO: Sign the new cert somehow with the old cert. See https://github.com/stackabletech/decisions/issues/56
10097
101- self . cert_tx
102- . send ( cert)
103- . await
104- . map_err ( |_err| CertificateResolverError :: SendCertificateToChannel ) ?;
105-
98+ Self :: send_certificate_to_channel ( cert, & self . cert_tx ) . await ?;
10699 self . current_certified_key . store ( certified_key) ;
107100
108101 Ok ( ( ) )
@@ -151,6 +144,16 @@ impl CertificateResolver {
151144 . await
152145 . context ( TokioSpawnBlockingSnafu ) ?
153146 }
147+
148+ async fn send_certificate_to_channel (
149+ cert : CertificateInner ,
150+ cert_tx : & mpsc:: Sender < Certificate > ,
151+ ) -> Result < ( ) > {
152+ cert_tx
153+ . send ( cert)
154+ . await
155+ . map_err ( |_err| CertificateResolverError :: SendCertificateToChannel )
156+ }
154157}
155158
156159impl ResolvesServerCert for CertificateResolver {
0 commit comments