File tree Expand file tree Collapse file tree 3 files changed +9
-12
lines changed Expand file tree Collapse file tree 3 files changed +9
-12
lines changed Original file line number Diff line number Diff line change
1
+ #![ allow( clippy:: unusual_byte_groupings) ]
1
2
use std:: env;
2
3
3
4
fn main ( ) {
Original file line number Diff line number Diff line change @@ -159,14 +159,14 @@ pub struct Identity {
159
159
impl Identity {
160
160
pub fn from_pkcs12 ( buf : & [ u8 ] , pass : & str ) -> Result < Identity , Error > {
161
161
let pkcs12 = Pkcs12 :: from_der ( buf) ?;
162
- let parsed = pkcs12. parse ( pass) ?;
162
+ let parsed = pkcs12. parse2 ( pass) ?;
163
163
Ok ( Identity {
164
- pkey : parsed. pkey ,
165
- cert : parsed. cert ,
164
+ pkey : parsed. pkey . ok_or_else ( || Error :: EmptyChain ) ? ,
165
+ cert : parsed. cert . ok_or_else ( || Error :: EmptyChain ) ? ,
166
166
// > The stack is the reverse of what you might expect due to the way
167
167
// > PKCS12_parse is implemented, so we need to load it backwards.
168
168
// > https://github.com/sfackler/rust-native-tls/commit/05fb5e583be589ab63d9f83d986d095639f8ec44
169
- chain : parsed. chain . into_iter ( ) . flatten ( ) . rev ( ) . collect ( ) ,
169
+ chain : parsed. ca . into_iter ( ) . flatten ( ) . rev ( ) . collect ( ) ,
170
170
} )
171
171
}
172
172
Original file line number Diff line number Diff line change @@ -106,13 +106,13 @@ impl Identity {
106
106
. filename ( "key.pem" )
107
107
. items ( & mut items)
108
108
. keychain ( & keychain)
109
- . import ( & key) ?;
109
+ . import ( key) ?;
110
110
111
111
ImportOptions :: new ( )
112
112
. filename ( "chain.pem" )
113
113
. items ( & mut items)
114
114
. keychain ( & keychain)
115
- . import ( & pem) ?;
115
+ . import ( pem) ?;
116
116
117
117
let cert = items
118
118
. certificates
@@ -121,7 +121,7 @@ impl Identity {
121
121
let ident = SecIdentity :: with_certificate ( & [ keychain] , cert) ?;
122
122
Ok ( Identity {
123
123
identity : ident,
124
- chain : items. certificates ,
124
+ chain : items. certificates . into_iter ( ) . skip ( 1 ) . collect ( ) ,
125
125
} )
126
126
}
127
127
@@ -507,11 +507,7 @@ impl<S: io::Read + io::Write> TlsStream<S> {
507
507
_ => return Ok ( None ) ,
508
508
} ;
509
509
510
- let algorithm = match section
511
- . iter ( )
512
- . filter ( |p| p. label ( ) . to_string ( ) == "Algorithm" )
513
- . next ( )
514
- {
510
+ let algorithm = match section. iter ( ) . find ( |p| p. label ( ) == "Algorithm" ) {
515
511
Some ( property) => property,
516
512
None => return Ok ( None ) ,
517
513
} ;
You can’t perform that action at this time.
0 commit comments