1
1
use std:: sync:: Arc ;
2
2
3
3
use arc_swap:: ArcSwap ;
4
- use snafu:: { ResultExt , Snafu } ;
4
+ use snafu:: { OptionExt , ResultExt , Snafu } ;
5
5
use stackable_certs:: { CertificatePairError , ca:: CertificateAuthority , keys:: ecdsa} ;
6
6
use tokio:: sync:: mpsc;
7
7
use tokio_rustls:: rustls:: {
8
- crypto:: ring :: default_provider , server:: ResolvesServerCert , sign:: CertifiedKey ,
8
+ crypto:: CryptoProvider , server:: ResolvesServerCert , sign:: CertifiedKey ,
9
9
} ;
10
10
use x509_cert:: Certificate ;
11
11
@@ -48,6 +48,9 @@ pub enum CertificateResolverError {
48
48
49
49
#[ snafu( display( "failed to run task in blocking thread" ) ) ]
50
50
TokioSpawnBlocking { source : tokio:: task:: JoinError } ,
51
+
52
+ #[ snafu( display( "no default rustls CryptoProvider installed" ) ) ]
53
+ NoDefaultCryptoProviderInstalled { } ,
51
54
}
52
55
53
56
/// This struct serves as [`ResolvesServerCert`] to always hand out the current certificate for TLS
@@ -113,7 +116,8 @@ impl CertificateResolver {
113
116
) -> Result < ( Certificate , Arc < CertifiedKey > ) > {
114
117
// The certificate generations can take a while, so we use `spawn_blocking`
115
118
tokio:: task:: spawn_blocking ( move || {
116
- let tls_provider = default_provider ( ) ;
119
+ let tls_provider =
120
+ CryptoProvider :: get_default ( ) . context ( NoDefaultCryptoProviderInstalledSnafu ) ?;
117
121
118
122
let ca_key = ecdsa:: SigningKey :: new ( ) . context ( GenerateEcdsaSigningKeySnafu ) ?;
119
123
let mut ca =
@@ -139,7 +143,10 @@ impl CertificateResolver {
139
143
CertifiedKey :: from_der ( vec ! [ certificate_der] , private_key_der, & tls_provider)
140
144
. context ( DecodeCertifiedKeyFromDerSnafu ) ?;
141
145
142
- Ok ( ( certificate_pair. certificate ( ) . clone ( ) , Arc :: new ( certificate_key) ) )
146
+ Ok ( (
147
+ certificate_pair. certificate ( ) . clone ( ) ,
148
+ Arc :: new ( certificate_key) ,
149
+ ) )
143
150
} )
144
151
. await
145
152
. context ( TokioSpawnBlockingSnafu ) ?
0 commit comments