File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,18 @@ impl CertificateMetadata {
220
220
/// Returns the set of trust bits expressed for this certificate. Panics if the raw
221
221
/// trust bits are invalid/unknown.
222
222
fn trust_bits ( & self ) -> HashSet < TrustBits > {
223
- self . trust_bits . split ( ';' ) . map ( TrustBits :: from) . collect ( )
223
+ let bits = self
224
+ . trust_bits
225
+ . split ( ';' )
226
+ . map ( TrustBits :: from)
227
+ . collect :: < HashSet < _ > > ( ) ;
228
+ if bits. contains ( & TrustBits :: AllTrustBitsTurnedOff ) && bits. len ( ) > 1 {
229
+ panic ! (
230
+ "unexpected trust bits: AllTrustBitsTurnedOff \
231
+ is mutually exclusive (found {bits:?})"
232
+ ) ;
233
+ }
234
+ bits
224
235
}
225
236
226
237
/// Returns the PEM metadata for the certificate with the leading/trailing single quotes
@@ -252,6 +263,8 @@ pub enum TrustBits {
252
263
Email ,
253
264
/// certificate is trusted for code signing
254
265
Code ,
266
+ /// certificate is not trusted for anything
267
+ AllTrustBitsTurnedOff ,
255
268
}
256
269
257
270
impl From < & str > for TrustBits {
@@ -260,6 +273,7 @@ impl From<&str> for TrustBits {
260
273
"Websites" => TrustBits :: Websites ,
261
274
"Email" => TrustBits :: Email ,
262
275
"Code" => TrustBits :: Code ,
276
+ "All Trust Bits Turned Off" => TrustBits :: AllTrustBitsTurnedOff ,
263
277
val => panic ! ( "unknown trust bit: {val:?}" ) ,
264
278
}
265
279
}
You can’t perform that action at this time.
0 commit comments