本文整理匯總了TypeScript中node-opcua-server.OPCUAServer.getPrivateKey方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript OPCUAServer.getPrivateKey方法的具體用法?TypeScript OPCUAServer.getPrivateKey怎麽用?TypeScript OPCUAServer.getPrivateKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類node-opcua-server.OPCUAServer
的用法示例。
在下文中一共展示了OPCUAServer.getPrivateKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: verifyServer
function verifyServer(server: OPCUAServer) {
debugLog("---------------------------------------------------------------");
const certificateChain1 = server.getCertificateChain();
debugLog("server.getCertificateChain() =",
makeSHA1Thumbprint(certificateChain1).toString("hex") + " l=" + certificateChain1.length);
const privateKey1 = convertPEMtoDER(server.getPrivateKey());
debugLog("server.getPrivateKey() =",
makeSHA1Thumbprint(privateKey1).toString("hex"));
const match = certificateMatchesPrivateKey(certificateChain1, privateKey1);
debugLog("math =", match);
for (const endpoint of server.endpoints) {
debugLog("endpoint ", endpoint.toString());
for (const e of endpoint.endpointDescriptions()) {
const certificateChain3 = e.serverCertificate;
debugLog("endpoint certificate =",
makeSHA1Thumbprint(certificateChain3).toString("hex") + " l=" + certificateChain3.length);
// xx console.log(e.toString());
}
}
debugLog("---------------------------------------------------------------");
}
示例2: it
it("SCT-1 should modify a server to support push certificate management", async () => {
const server = new OPCUAServer({
port: 20000,
serverCertificateManager: certificateManager,
userCertificateManager: certificateManager
});
await server.initialize();
await installPushCertificateManagementOnServer(server);
const privateKey1PEM = await promisify(fs.readFile)(server.serverCertificateManager.privateKey, "utf8");
const privateKey1 = convertPEMtoDER(privateKey1PEM);
const privateKey2 = convertPEMtoDER(server.getPrivateKey());
privateKey1.toString("base64").should.eql(privateKey2.toString("base64"));
// now start the server
await server.start();
// now stop the server
await server.shutdown();
});