|
1 | 1 | //! openssl module
|
2 |
| -use std::fmt::{self, Debug, Formatter}; |
| 2 | +use std::fmt::{self, Debug, Formatter}; |
3 | 3 | use std::fs::File;
|
4 | 4 | use std::future::{Ready, ready};
|
5 | 5 | use std::io::{Error as IoError, Read, Result as IoResult};
|
6 | 6 | use std::path::Path;
|
7 | 7 |
|
8 |
| -use futures_util::stream::{once, Once, Stream}; |
| 8 | +use futures_util::stream::{Once, Stream, once}; |
9 | 9 | use openssl::pkey::PKey;
|
10 | 10 | use openssl::ssl::{SslAcceptor, SslMethod};
|
11 | 11 | use openssl::x509::X509;
|
@@ -166,7 +166,13 @@ impl OpensslConfig {
|
166 | 166 | builder.set_alpn_protos(&self.alpn_protocols)?;
|
167 | 167 | // set uo ALPN selection routine - as select_next_proto
|
168 | 168 | builder.set_alpn_select_callback(move |_, list| {
|
169 |
| - openssl::ssl::select_next_proto(&alpn_protocols, list).ok_or(openssl::ssl::AlpnError::NOACK) |
| 169 | + let proto = openssl::ssl::select_next_proto(&alpn_protocols, list) |
| 170 | + .ok_or(openssl::ssl::AlpnError::NOACK)?; |
| 171 | + let pos = list |
| 172 | + .windows(proto.len()) |
| 173 | + .position(|window| window == proto) |
| 174 | + .expect("selected alpn proto should be present in client protos"); |
| 175 | + Ok(&list[pos..pos + proto.len()]) |
170 | 176 | });
|
171 | 177 | if let Some(modifier) = &mut self.builder_modifier {
|
172 | 178 | modifier(&mut builder);
|
|
0 commit comments