本文整理汇总了TypeScript中tls.createSecureContext函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createSecureContext函数的具体用法?TypeScript createSecureContext怎么用?TypeScript createSecureContext使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createSecureContext函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
decipherBuffers.push(decipher.update(cipherText));
decipherBuffers.push(decipher.final());
let clearText2: Buffer = Buffer.concat(decipherBuffers);
assert.deepEqual(clearText2, clearText);
}
}
//////////////////////////////////////////////////
/// TLS tests : http://nodejs.org/api/tls.html ///
//////////////////////////////////////////////////
namespace tls_tests {
var ctx: tls.SecureContext = tls.createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
var blah = ctx.context;
var connOpts: tls.ConnectionOptions = {
host: "127.0.0.1",
port: 55
};
var tlsSocket = tls.connect(connOpts);
}
////////////////////////////////////////////////////
/// Http tests : http://nodejs.org/api/http.html ///
////////////////////////////////////////////////////
namespace http_tests {
示例2: createSecureContext
import { createSecureContext, SecureContext, ConnectionOptions, connect, getCiphers, DEFAULT_ECDH_CURVE, createServer, TLSSocket } from "tls";
import * as fs from "fs";
{
const ctx: SecureContext = createSecureContext({
key: "NOT REALLY A KEY",
cert: "SOME CERTIFICATE",
});
const blah = ctx.context;
const connOpts: ConnectionOptions = {
host: "127.0.0.1",
port: 55
};
const tlsSocket = connect(connOpts);
const ciphers: string[] = getCiphers();
const curve: string = DEFAULT_ECDH_CURVE;
}
{
const _server = createServer();
_server.addContext("example", {
cert: fs.readFileSync("cert_filepath"),
key: fs.readFileSync("key_filepath")
});
}
{
let _server = createServer({});