Развернуть все
Свернуть все

Создание запроса на выпуск сертификата

HTML
<script language="javascript" src="cadesplugin_api.js"></script>

В данном примере создается запрос на выпуск сертификата

JavaScript
        var PKey = cadesplugin.CreateObject("X509Enrollment.CX509PrivateKey");
        PKey.ProviderName = "Crypto-Pro GOST R 34.10-2001";
        PKey.ProviderType = 75;
        PKey.KeySpec = keyExchange;  // XCN_AT_KEYEXCHANGE

        var CertificateRequestPkcs10 = cadesplugin.CreateObject("X509Enrollment.CX509CertificateRequestPkcs10");
        CertificateRequestPkcs10.InitializeFromPrivateKey(0x1, PKey, "");

        var DistinguishedName = cadesplugin.CreateObject("X509Enrollment.CX500DistinguishedName");
        DistinguishedName.Encode("CN=\"TestName\";");
        CertificateRequestPkcs10.Subject = DistinguishedName;

        var KeyUsageExtension = cadesplugin.CreateObject("X509Enrollment.CX509ExtensionKeyUsage");
        var CERT_DATA_ENCIPHERMENT_KEY_USAGE = 0x10;
        var CERT_KEY_ENCIPHERMENT_KEY_USAGE = 0x20;
        var CERT_DIGITAL_SIGNATURE_KEY_USAGE = 0x80;
        var CERT_NON_REPUDIATION_KEY_USAGE = 0x40;

        KeyUsageExtension.InitializeEncode(
                    CERT_KEY_ENCIPHERMENT_KEY_USAGE |
                    CERT_DATA_ENCIPHERMENT_KEY_USAGE |
                    CERT_DIGITAL_SIGNATURE_KEY_USAGE |
                    CERT_NON_REPUDIATION_KEY_USAGE);
        CertificateRequestPkcs10.X509Extensions.Add(KeyUsageExtension);

        var Enroll = cadesplugin.CreateObject("X509Enrollment.CX509Enrollment");
        Enroll.InitializeFromRequest(CertificateRequestPkcs10);
        
        var certReq = Enroll.CreateRequest(encodingTypeNum);