@@ -11,8 +11,7 @@ use std::mem::{mod, transmute, transmute_copy};
11
11
use std:: raw:: { mod, TraitObject } ;
12
12
13
13
use uany:: UncheckedBoxAnyDowncast ;
14
- use openssl:: ssl:: { Ssl , SslStream , SslContext , VerifyCallback } ;
15
- use openssl:: ssl:: SslVerifyMode :: SslVerifyPeer ;
14
+ use openssl:: ssl:: { Ssl , SslStream , SslContext } ;
16
15
use openssl:: ssl:: SslMethod :: Sslv23 ;
17
16
use openssl:: ssl:: error:: { SslError , StreamError , OpenSslErrors , SslSessionClosed } ;
18
17
@@ -240,7 +239,10 @@ impl NetworkStream for HttpStream {
240
239
241
240
/// A connector that will produce HttpStreams.
242
241
#[ allow( missing_copy_implementations) ]
243
- pub struct HttpConnector ( pub Option < VerifyCallback > ) ;
242
+ pub struct HttpConnector ( pub Option < ContextVerifier > ) ;
243
+
244
+ /// Can set various verification schemes on the SSL context
245
+ pub type ContextVerifier = for <' a > fn ( & ' a mut SslContext ) -> ( ) ;
244
246
245
247
impl NetworkConnector < HttpStream > for HttpConnector {
246
248
fn connect ( & mut self , host : & str , port : Port , scheme : & str ) -> IoResult < HttpStream > {
@@ -254,7 +256,7 @@ impl NetworkConnector<HttpStream> for HttpConnector {
254
256
debug ! ( "https scheme" ) ;
255
257
let stream = try!( TcpStream :: connect ( addr) ) ;
256
258
let mut context = try!( SslContext :: new ( Sslv23 ) . map_err ( lift_ssl_error) ) ;
257
- self . 0 . as_ref ( ) . map ( |cb| context . set_verify ( SslVerifyPeer , Some ( * cb ) ) ) ;
259
+ self . 0 . map ( |cb| cb ( & mut context ) ) ;
258
260
let ssl = try!( Ssl :: new ( & context) . map_err ( lift_ssl_error) ) ;
259
261
try!( ssl. set_hostname ( host) . map_err ( lift_ssl_error) ) ;
260
262
let stream = try!( SslStream :: new ( & context, stream) . map_err ( lift_ssl_error) ) ;
0 commit comments