File tree Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 21
21
- /usr/local/cargo/registry/index
22
22
- restore_cache :
23
23
key : deps-<< parameters.image >>-{{ checksum "Cargo.lock" }}
24
- - run : cargo test
24
+ - run : cargo test --features alpn
25
25
- run : rustdoc --test README.md -L target/debug/deps -L target/debug
26
26
- save_cache :
27
27
key : deps-<< parameters.image >>-{{ checksum "Cargo.lock" }}
51
51
- ~/.cargo/registry/index
52
52
- restore_cache :
53
53
key : macos-deps-<< parameters.version >>
54
- - run : cargo test
54
+ - run : cargo test --features alpn
55
55
- save_cache :
56
56
key : macos-deps-<< parameters.version >>
57
57
paths :
Original file line number Diff line number Diff line change @@ -10,8 +10,11 @@ readme = "README.md"
10
10
[features ]
11
11
vendored = [" openssl/vendored" ]
12
12
13
+ # Switch for MacOS to keep support for older versions, Windows targets and openssl target will have alpn regardless
14
+ alpn = [" security-framework/alpn" ]
15
+
13
16
[target .'cfg(any(target_os = "macos", target_os = "ios"))' .dependencies ]
14
- security-framework = { version = " 2.0.0" , features = [ " alpn " ]}
17
+ security-framework = " 2.0.0"
15
18
security-framework-sys = " 2.0.0"
16
19
lazy_static = " 1.4.0"
17
20
libc = " 0.2"
Original file line number Diff line number Diff line change @@ -656,10 +656,11 @@ impl<S: io::Read + io::Write> TlsStream<S> {
656
656
657
657
/// Returns the negotiated ALPN protocols
658
658
pub fn negotiated_alpn ( & self ) -> Result < Option < String > > {
659
- Ok ( self
659
+ let protocol = self
660
660
. 0
661
661
. negotiated_alpn ( ) ?
662
- . map ( |bytes| String :: from_utf8 ( bytes) . unwrap ( ) ) ) //negotiated_alpn always returns valid utf-8
662
+ . map ( |bytes| String :: from_utf8_lossy ( & bytes) . into_owned ( ) ) ;
663
+ Ok ( protocol)
663
664
}
664
665
665
666
/// Shuts down the TLS session.
Original file line number Diff line number Diff line change @@ -420,6 +420,7 @@ mod tests {
420
420
}
421
421
422
422
#[ test]
423
+ #[ cfg_attr( not( feature = "alpn" ) , ignore) ]
423
424
fn alpn_google_h2 ( ) {
424
425
let builder = p ! ( TlsConnector :: builder( ) . request_alpns( & [ "h2" ] ) . build( ) ) ;
425
426
let s = p ! ( TcpStream :: connect( "google.com:443" ) ) ;
@@ -434,6 +435,7 @@ mod tests {
434
435
}
435
436
436
437
#[ test]
438
+ #[ cfg_attr( not( feature = "alpn" ) , ignore) ]
437
439
fn alpn_google_invalid ( ) {
438
440
let builder = p ! ( TlsConnector :: builder( ) . request_alpns( & [ "h2c" ] ) . build( ) ) ;
439
441
let s = p ! ( TcpStream :: connect( "google.com:443" ) ) ;
@@ -448,6 +450,7 @@ mod tests {
448
450
}
449
451
450
452
#[ test]
453
+ #[ cfg_attr( not( feature = "alpn" ) , ignore) ]
451
454
fn alpn_google_none ( ) {
452
455
let builder = p ! ( TlsConnector :: new( ) ) ;
453
456
let s = p ! ( TcpStream :: connect( "google.com:443" ) ) ;
You can’t perform that action at this time.
0 commit comments