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) ]
12use std:: env;
23
34fn main ( ) {
Original file line number Diff line number Diff line change @@ -159,14 +159,14 @@ pub struct Identity {
159159impl Identity {
160160 pub fn from_pkcs12 ( buf : & [ u8 ] , pass : & str ) -> Result < Identity , Error > {
161161 let pkcs12 = Pkcs12 :: from_der ( buf) ?;
162- let parsed = pkcs12. parse ( pass) ?;
162+ let parsed = pkcs12. parse2 ( pass) ?;
163163 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 ) ? ,
166166 // > The stack is the reverse of what you might expect due to the way
167167 // > PKCS12_parse is implemented, so we need to load it backwards.
168168 // > 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 ( ) ,
170170 } )
171171 }
172172
Original file line number Diff line number Diff line change @@ -106,13 +106,13 @@ impl Identity {
106106 . filename ( "key.pem" )
107107 . items ( & mut items)
108108 . keychain ( & keychain)
109- . import ( & key) ?;
109+ . import ( key) ?;
110110
111111 ImportOptions :: new ( )
112112 . filename ( "chain.pem" )
113113 . items ( & mut items)
114114 . keychain ( & keychain)
115- . import ( & pem) ?;
115+ . import ( pem) ?;
116116
117117 let cert = items
118118 . certificates
@@ -121,7 +121,7 @@ impl Identity {
121121 let ident = SecIdentity :: with_certificate ( & [ keychain] , cert) ?;
122122 Ok ( Identity {
123123 identity : ident,
124- chain : items. certificates ,
124+ chain : items. certificates . into_iter ( ) . skip ( 1 ) . collect ( ) ,
125125 } )
126126 }
127127
@@ -507,11 +507,7 @@ impl<S: io::Read + io::Write> TlsStream<S> {
507507 _ => return Ok ( None ) ,
508508 } ;
509509
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" ) {
515511 Some ( property) => property,
516512 None => return Ok ( None ) ,
517513 } ;
You can’t perform that action at this time.
0 commit comments