File tree Expand file tree Collapse file tree 4 files changed +13
-7
lines changed
runtime/swimos_remote/src/tls
server/swimos_server_app/src/server/builder Expand file tree Collapse file tree 4 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ impl SwimClientTlsBuilder {
140
140
RustlsClientNetworking :: build (
141
141
Arc :: new ( Resolver :: new ( ) . await ) ,
142
142
tls_config,
143
- crypto_provider. build ( ) ,
143
+ crypto_provider. try_build ( ) ? ,
144
144
) ?,
145
145
)
146
146
. await )
Original file line number Diff line number Diff line change @@ -32,4 +32,6 @@ pub enum TlsError {
32
32
/// Performing the TLS handshake failed.
33
33
#[ error( "TLS handshake failed: {0}" ) ]
34
34
HandshakeFailed ( std:: io:: Error ) ,
35
+ #[ error( "Invalid cryptographic provider configured: {0}" ) ]
36
+ InvalidCryptoProvider ( String ) ,
35
37
}
Original file line number Diff line number Diff line change @@ -35,11 +35,15 @@ pub enum CryptoProviderConfig {
35
35
}
36
36
37
37
impl CryptoProviderConfig {
38
- pub fn build ( self ) -> Arc < CryptoProvider > {
38
+ pub fn try_build ( self ) -> Result < Arc < CryptoProvider > , TlsError > {
39
39
match self {
40
40
CryptoProviderConfig :: ProcessDefault => CryptoProvider :: get_default ( )
41
- . expect ( "No default cryptographic provider specified" )
42
- . clone ( ) ,
41
+ . ok_or_else ( || {
42
+ TlsError :: InvalidCryptoProvider (
43
+ "No default cryptographic provider specified" . to_string ( ) ,
44
+ )
45
+ } )
46
+ . cloned ( ) ,
43
47
CryptoProviderConfig :: FromFeatureFlags => {
44
48
#[ cfg( all( feature = "ring_provider" , not( feature = "aws_lc_rs_provider" ) ) ) ]
45
49
{
@@ -53,10 +57,10 @@ impl CryptoProviderConfig {
53
57
54
58
#[ allow( unreachable_code) ]
55
59
{
56
- panic ! ( "Ambiguous cryptographic provider feature flags specified. Only \" ring_provider\" or \" aws_lc_rs_provider\" may be specified" )
60
+ Err ( TlsError :: InvalidCryptoProvider ( "Ambiguous cryptographic provider feature flags specified. Only \" ring_provider\" or \" aws_lc_rs_provider\" may be specified" . to_string ( ) ) )
57
61
}
58
62
}
59
- CryptoProviderConfig :: Provided ( provider) => provider,
63
+ CryptoProviderConfig :: Provided ( provider) => Ok ( provider) ,
60
64
}
61
65
}
62
66
}
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ impl ServerBuilder {
200
200
deflate,
201
201
introspection,
202
202
} ;
203
- let crypto_provider = crypto_provider. build ( ) ;
203
+ let crypto_provider = crypto_provider. try_build ( ) ? ;
204
204
205
205
if let Some ( tls_conf) = tls_config {
206
206
let client =
You can’t perform that action at this time.
0 commit comments