Exemple #1
0
 public CertificateRequest
 (
     CertificateSubject subject,
     SigningRequestProtocol csrProtocol,
     bool managedPrivateKey
 )
 {
     this.Subject = subject;
     this.SigningRequestProtocol = csrProtocol;
     this.ManagedPrivateKey      = managedPrivateKey;
 }
        /// <summary>
        /// Creates a new public and private key pair and the encoded csr is returned back in the CertificateRequest object.
        /// For security reasons, the private key is kept on the machine that this method is invoked on.
        /// The next step is to have a certificate authority sign the csr and the result should be provided to the InstallIssuedCertificate method.
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="cipher"></param>
        /// <param name="keysize"></param>
        /// <param name="api"></param>
        /// <param name="protocol"></param>
        /// <returns></returns>
        public CertificateRequest CreateCsrKeyPair(CertificateSubject subject, CipherAlgorithm cipher, int keysize, WindowsApi api, SigningRequestProtocol protocol)
        {
            if (!requestValidation.IsValidWindowsApiForCipherAlgorithm(cipher, api))
            {
                throw new AlgorithmNotSupportedByProviderException("The cryptography provider specified does not support the specified cipher algorithm");
            }

            CX509PrivateKey privateKey = CreatePrivateKey(cipher, keysize, api);

            return(CreateCsrFromPrivateKey(subject, cipher, keysize, privateKey));
        }