File tree 2 files changed +28
-0
lines changed 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ fn main() {
49
49
println ! ( "cargo:rustc-cfg=ossl111" ) ;
50
50
}
51
51
}
52
+ if let Ok ( v) = env:: var ( "DEP_OPENSSL_CONF" ) {
53
+ for conf in v. split ( ',' ) {
54
+ println ! ( "cargo:rustc-cfg=osslconf=\" {}\" " , conf) ;
55
+ }
56
+ }
52
57
}
53
58
54
59
fn git_hash ( ) -> String {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ mod sys {
42
42
pub fn X509_get_version ( x : * const X509 ) -> c_long ;
43
43
pub fn SSLv3_method ( ) -> * const SSL_METHOD ;
44
44
pub fn TLSv1_method ( ) -> * const SSL_METHOD ;
45
+ pub fn COMP_get_type ( meth : * const COMP_METHOD ) -> i32 ;
45
46
}
46
47
}
47
48
@@ -695,6 +696,28 @@ impl PySslSocket {
695
696
. map ( cipher_to_tuple)
696
697
}
697
698
699
+ #[ pymethod]
700
+ fn compression ( & self ) -> Option < & ' static str > {
701
+ #[ cfg( osslconf = "OPENSSL_NO_COMP" ) ]
702
+ {
703
+ None
704
+ }
705
+ #[ cfg( not( osslconf = "OPENSSL_NO_COMP" ) ) ]
706
+ {
707
+ let stream = self . stream . read ( ) ;
708
+ let comp_method = unsafe { sys:: SSL_get_current_compression ( stream. ssl ( ) . as_ptr ( ) ) } ;
709
+ if comp_method. is_null ( ) {
710
+ return None ;
711
+ }
712
+ let typ = unsafe { sys:: COMP_get_type ( comp_method) } ;
713
+ let nid = Nid :: from_raw ( typ) ;
714
+ if nid == Nid :: UNDEF {
715
+ return None ;
716
+ }
717
+ nid. short_name ( ) . ok ( )
718
+ }
719
+ }
720
+
698
721
#[ pymethod]
699
722
fn do_handshake ( & self , vm : & VirtualMachine ) -> PyResult < ( ) > {
700
723
let mut stream = self . stream . write ( ) ;
You can’t perform that action at this time.
0 commit comments