本文整理匯總了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({});