File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -111,8 +111,9 @@ impl Identity {
111
111
)
112
112
} ) ?) ?;
113
113
114
+ let name = gen_container_name ( ) ;
114
115
let mut options = AcquireOptions :: new ( ) ;
115
- options. container ( "schannel" ) ;
116
+ options. container ( & name ) ;
116
117
let type_ = ProviderType :: rsa_full ( ) ;
117
118
118
119
let mut container = match options. acquire ( type_) {
@@ -122,7 +123,7 @@ impl Identity {
122
123
container. import ( ) . import_pkcs8_pem ( & key) ?;
123
124
124
125
cert. set_key_prov_info ( )
125
- . container ( "schannel" )
126
+ . container ( & name )
126
127
. type_ ( type_)
127
128
. keep_open ( true )
128
129
. key_spec ( KeySpec :: key_exchange ( ) )
@@ -137,6 +138,13 @@ impl Identity {
137
138
}
138
139
}
139
140
141
+ // The name of the container must be unique to have multiple active keys.
142
+ fn gen_container_name ( ) -> String {
143
+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
144
+ static COUNTER : AtomicUsize = AtomicUsize :: new ( 0 ) ;
145
+ format ! ( "native-tls-{}" , COUNTER . fetch_add( 1 , Ordering :: Relaxed ) )
146
+ }
147
+
140
148
#[ derive( Clone ) ]
141
149
pub struct Certificate ( CertContext ) ;
142
150
You can’t perform that action at this time.
0 commit comments