Deno.connectTls

\color{red}{function} Deno.connectTls (options: ConnectTlsOptions): Promise<Conn>

\color{red}{作用}

使用可选的证书文件,主机名(默认为“ 127.0.0.1”)和端口在TLS(传输层安全性)上建立安全连接。
cert文件是可选的,如果未包含,则将使用Mozilla的根证书(有关详细信息,另请参见https://github.com/ctz/webpki-roots

原文: Establishes a secure connection over TLS (transport layer security) using an optional cert file, hostname (default is "127.0.0.1") and port. The cert file is optional and if not included Mozilla's root certificates will be used (see also https://github.com/ctz/webpki-roots for specifics)

\color{red}{参数}

port : number
hostname? : string (默认值:127.0.0.1)
certFile? : string

原文:
port : number (The port to connect to.)
hostname? : string (A literal IP address or host name that can be resolved to an IP address. If not specified, defaults to 127.0.0.1.)
certFile? : string

\color{red}{返回值}

Promise<Conn>

原文: Promise<Conn>

\color{red}{示列代码}

const conn1 = await Deno.connectTls({ port: 80 });
const conn2 = await Deno.connectTls({ certFile: "./certs/my_custom_root_CA.pem", hostname: "192.0.2.1", port: 80 });
const conn3 = await Deno.connectTls({ hostname: "[2001:db8::1]", port: 80 });
const conn4 = await Deno.connectTls({ certFile: "./certs/my_custom_root_CA.pem", hostname: "golang.org", port: 80});

\color{red}{其它}

需要提供 allow-net 权限。

Requires allow-net permission for "tcp".

原文地址:点此跳转

Deno 目录

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容