當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。