File tree 3 files changed +18
-0
lines changed
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1001,6 +1001,16 @@ declare namespace Deno {
1001
1001
options ?: StartTlsOptions ,
1002
1002
) : Promise < Conn > ;
1003
1003
1004
+ export interface ListenTlsOptions {
1005
+ /** **UNSTABLE**: new API, yet to be vetted.
1006
+ *
1007
+ * Application-Layer Protocol Negotiation (ALPN) protocols to announce to
1008
+ * the client. If not specified, no ALPN extension will be included in the
1009
+ * TLS handshake.
1010
+ */
1011
+ alpnProtocols ?: string [ ] ;
1012
+ }
1013
+
1004
1014
/** **UNSTABLE**: The `signo` argument may change to require the Deno.Signal
1005
1015
* enum.
1006
1016
*
Original file line number Diff line number Diff line change 51
51
keyFile,
52
52
hostname = "0.0.0.0" ,
53
53
transport = "tcp" ,
54
+ alpnProtocols,
54
55
} ) {
55
56
const res = opListenTls ( {
56
57
port,
57
58
certFile,
58
59
keyFile,
59
60
hostname,
60
61
transport,
62
+ alpnProtocols,
61
63
} ) ;
62
64
return new TLSListener ( res . rid , res . localAddr ) ;
63
65
}
Original file line number Diff line number Diff line change @@ -300,6 +300,7 @@ pub struct ListenTlsArgs {
300
300
port : u16 ,
301
301
cert_file : String ,
302
302
key_file : String ,
303
+ alpn_protocols : Option < Vec < String > > ,
303
304
}
304
305
305
306
fn op_listen_tls (
@@ -318,6 +319,11 @@ fn op_listen_tls(
318
319
permissions. read . check ( Path :: new ( & key_file) ) ?;
319
320
}
320
321
let mut config = ServerConfig :: new ( NoClientAuth :: new ( ) ) ;
322
+ if let Some ( alpn_protocols) = args. alpn_protocols {
323
+ super :: check_unstable ( state, "Deno.listenTls#alpn_protocols" ) ;
324
+ config. alpn_protocols =
325
+ alpn_protocols. into_iter ( ) . map ( |s| s. into_bytes ( ) ) . collect ( ) ;
326
+ }
321
327
config
322
328
. set_single_cert ( load_certs ( & cert_file) ?, load_keys ( & key_file) ?. remove ( 0 ) )
323
329
. expect ( "invalid key or certificate" ) ;
You can’t perform that action at this time.
0 commit comments