コード例 #1
0
        /// <summary>
        /// Create and sign the new certificate.
        /// </summary>
        /// <param name="subject">The complete subject list</param>
        /// <param name="certificatePassPhrase">The certificate request password</param>
        /// <param name="caPassPhrase">The root certificate authority password.</param>
        /// <param name="certificatePath">The certificate full path and file name.</param>
        /// <param name="multiDomain">Use the multi domain configuration arguments</param>
        public void CreateCertificate(Subject subject, string certificatePassPhrase, string caPassPhrase, string certificatePath, bool multiDomain = false)
        {
            if (subject == null)
            {
                throw new ArgumentNullException("subject");
            }
            if (String.IsNullOrEmpty(caPassPhrase))
            {
                throw new ArgumentNullException("caPassPhrase");
            }
            if (String.IsNullOrEmpty(certificatePath))
            {
                throw new ArgumentNullException("certificatePath");
            }

            // Get each file name
            string requestPath = Helper.GetRequestPath(certificatePath);
            string certPath    = Helper.GetCertificatePath(certificatePath);

            // Create a new certificate request.
            CertificateRequest request = new CertificateRequest(_openSslExecutablePath, _openSslConfigurationPath);

            request.Create(subject, certificatePassPhrase, requestPath, multiDomain);

            // Sign the certificate with the roor certificate authority
            CertificateSigning sign = new CertificateSigning(_openSslExecutablePath, _openSslConfigurationPath);

            sign.Sign(caPassPhrase, requestPath, certPath, multiDomain);
        }
コード例 #2
0
        /// <summary>
        /// Sign the new certificate request.
        /// </summary>
        /// <param name="caPassPhrase">The root certificate authority password.</param>
        /// <param name="certificateRequestPath">The full path and file name of the certificate request.</param>
        /// <param name="certificatePath">The certificate full path and file name.</param>
        public void SignCertificateMultiDomain(string caPassPhrase, string certificateRequestPath, string certificatePath)
        {
            if (String.IsNullOrEmpty(caPassPhrase))
            {
                throw new ArgumentNullException("caPassPhrase");
            }
            if (String.IsNullOrEmpty(certificateRequestPath))
            {
                throw new ArgumentNullException("certificateRequestPath");
            }
            if (String.IsNullOrEmpty(certificatePath))
            {
                throw new ArgumentNullException("certificatePath");
            }

            // Sign the certificate with the roor certificate authority
            CertificateSigning sign = new CertificateSigning(
                Nequeo.Security.OpenSsl.Properties.Settings.Default.OpenSSLExecutable,
                Nequeo.Security.OpenSsl.Properties.Settings.Default.OpenSSLMultiDomainConfiguration);

            // Sign the certificate
            sign.Sign(caPassPhrase, certificateRequestPath, certificatePath, true);
        }