当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript node-opcua-crypto.split_der函数代码示例

本文整理汇总了TypeScript中node-opcua-crypto.split_der函数的典型用法代码示例。如果您正苦于以下问题:TypeScript split_der函数的具体用法?TypeScript split_der怎么用?TypeScript split_der使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了split_der函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

    it("applyChanges shall replace certificate ", async () => {

        // given a PushCertificateManager that has received a new certificate
        const resultCSR = await pushManager.createSigningRequest(
          "DefaultApplicationGroup",
          "",
          "O=NodeOPCUA, CN=urn:NodeOPCUA-Server");
        resultCSR.certificateSigningRequest!.should.be.instanceOf(Buffer);

        const certificateFull = await produceCertificate(resultCSR.certificateSigningRequest!);
        const certificateChain = split_der(certificateFull);
        const certificate = certificateChain[0];
        const issuerCertificates = certificateChain.slice(1);

        const result: UpdateCertificateResult = await pushManager.updateCertificate(
          "DefaultApplicationGroup",
          "",
          certificate,
          issuerCertificates
        );
        // and Given
        const existingCertificate1 = await getCertificateDER(pushManager.applicationGroup!);

        // When I call ApplyChanges
        await pushManager.applyChanges();

        // Then I should verify that the certificate has changed
        const existingCertificateAfterApplyChange = await getCertificateDER(pushManager.applicationGroup!);
        existingCertificateAfterApplyChange.toString("hex").
          should.not.eql(existingCertificate1.toString("hex"));
    });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:test_push_certificate_manager_server_impl.ts

示例2: getCertificate

 public getCertificate(): Certificate {
     if (!this.certificate) {
         const certChain = this.getCertificateChain();
         this.certificate = split_der(certChain)[0] as Certificate;
     }
     return this.certificate;
 }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:7,代码来源:opcua_secure_object.ts

示例3: getCertificate

function getCertificate(this: OPCUAServerPartial): Certificate {
    if (!this.$$certificate) {
        const certificateChain = getCertificateChain.call(this);
        this.$$certificate = split_der(certificateChain)[0];
    }
    return this.$$certificate!;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:7,代码来源:install_push_certitifate_management.ts

示例4: function

            getCertificate: function() {

                const chain = this.getCertificateChain();

                const firstCertificateInChain = split_der(chain)[0];
                return firstCertificateInChain!;
            },
开发者ID:node-opcua,项目名称:node-opcua,代码行数:7,代码来源:test_security.ts

示例5: verifyX509UserIdentity

function verifyX509UserIdentity(
  serverCertificate: Certificate,
  sessionNonce: Buffer,
  securityPolicy: SecurityPolicy,
  userTokenPolicy: UserIdentityToken,
  userIdentityToken: X509IdentityToken,
  userTokenSignature: SignatureData,
  callback: (err: null, statusCode: StatusCode) => void
) {

    const cryptoFactory = getCryptoFactory(securityPolicy);
    if (!cryptoFactory) {
        return callback(null, StatusCodes.BadSecurityPolicyRejected);
    }

    if (!userTokenSignature || !userTokenSignature.signature) {
        return callback(null, StatusCodes.BadUserSignatureInvalid);
    }

    if (userIdentityToken.policyId !== userTokenPolicy.policyId) {
        console.log("invalid encryptionAlgorithm");
        console.log("userTokenPolicy", userTokenPolicy.toString());
        console.log("userTokenPolicy", userIdentityToken.toString());
        return callback(null, StatusCodes.BadSecurityPolicyRejected);
    }
    const certificate = userIdentityToken.certificateData/* as Certificate*/;

    const parts = split_der(certificate);

    const nonce = sessionNonce;
    assert(certificate instanceof Buffer, "expecting certificate to be a Buffer");
    assert(nonce instanceof Buffer, "expecting nonce to be a Buffer");
    assert(userTokenSignature.signature instanceof Buffer, "expecting userTokenSignature to be a Buffer");

    // verify proof of possession by checking certificate signature & server nonce correctness
    if (!verifySignature(serverCertificate, nonce, userTokenSignature, certificate, securityPolicy)) {
        return callback(null, StatusCodes.BadUserSignatureInvalid);
    }

    return callback(null, StatusCodes.Good);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:41,代码来源:test_x509_signature.ts

示例6: getSignatureLength

 public getSignatureLength(): PublicKeyLength {
     const chain = this.getCertificateChain();
     const firstCertificateInChain = split_der(chain)[0];
     const cert = exploreCertificateInfo(firstCertificateInChain);
     return cert.publicKeyLength; // 1024 bits = 128Bytes or 2048=256Bytes
 }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:6,代码来源:server_secure_channel_layer.ts

示例7: replaceServerCertificateUsingPushCertificateManagerMethod

    async function replaceServerCertificateUsingPushCertificateManagerMethod(endpointUrl: string): Promise<Certificate> {

        const client = OPCUAClient.create({
            certificateFile: clientCertificateFile,
            privateKeyFile: clientPrivateKeyFile,

            securityMode: MessageSecurityMode.SignAndEncrypt,
            securityPolicy: SecurityPolicy.Basic256

        });

        try {

            await client.connect(endpointUrl);

            const userIdentityToken: UserIdentityInfoUserName = {
                type: UserTokenType.UserName,

                password: "secret",
                userName: "admin"
            };

            const session = await client.createSession(userIdentityToken);

            const pm = new ClientPushCertificateManagement(session);

            const response = await pm.createSigningRequest(
              "DefaultApplicationGroup",
              NodeId.nullNodeId,
              "CN=MyApplication");

            debugLog(" cert request status",
              response.statusCode.toString());
            if (response.statusCode !== StatusCodes.Good) {
                throw new Error("Cannot get signing request from server : " + response.statusCode.toString());
            }
            debugLog(" cert request       ",
              response.certificateSigningRequest!.toString("base64"));

            const certificateFull = await produceCertificate(response.certificateSigningRequest!);

            const certificateChain = split_der(certificateFull);
            const certificate = certificateChain[0];
            const issuerCertificates = certificateChain.slice(1);

            // generate some certificate
            const response2 = await pm.updateCertificate(
              "DefaultApplicationGroup",
              NodeId.nullNodeId,
              certificate,
              issuerCertificates
            );
            debugLog(" updateCertificate  status", response2.statusCode.toString());
            if (response2.statusCode !== StatusCodes.Good) {
                throw new Error("Cannot updateCertificate " + response2.statusCode.toString());
            }

            await pm.applyChanges();

            await session.close();

            return certificateFull;

        } catch (err) {
            console.log("err =", err);
            throw err;
        } finally {
            await client.disconnect();
        }

    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:71,代码来源:test_server_with_push_certificate_management.ts


注:本文中的node-opcua-crypto.split_der函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。