Example #1
0
        private POSTCertificateEnrollmentResponse EnrollDV(EnrollmentProductInfo productInfo, string csr, Dictionary <string, string[]> san)
        {
            POSTCertificatesV1DVRequest certRequest = new POSTCertificatesV1DVRequest();

            certRequest.contact           = new ContactInfo();
            certRequest.contact.email     = productInfo.ProductParameters["Email"];
            certRequest.contact.nameFirst = productInfo.ProductParameters["FirstName"];
            certRequest.contact.nameLast  = productInfo.ProductParameters["LastName"];
            certRequest.contact.phone     = productInfo.ProductParameters["Phone"];
            certRequest.SetCSR(csr);

            certRequest.period      = Convert.ToInt32(productInfo.ProductParameters["CertificatePeriodInYears"]);
            certRequest.productType = productInfo.ProductID;
            certRequest.rootType    = _rootType;
            certRequest.slotSize    = productInfo.ProductParameters.Keys.Contains("SlotSize") ? productInfo.ProductParameters["SlotSize"] : "FIVE";

            List <string> sans = new List <string>();

            foreach (string[] sanValues in san.Values)
            {
                foreach (string sanValue in sanValues)
                {
                    sans.Add(sanValue);
                }
            }
            certRequest.subjectAlternativeNames = sans.ToArray();

            string response = _api.EnrollCSR(csr, certRequest);

            return(JsonConvert.DeserializeObject <POSTCertificateEnrollmentResponse>(response));
        }
Example #2
0
        private POSTCertificateEnrollmentResponse EnrollEV(EnrollmentProductInfo productInfo, string csr, Dictionary <string, string[]> san)
        {
            POSTCertificatesV1EVRequest certRequest = new POSTCertificatesV1EVRequest();

            certRequest.contact           = new ContactInfo();
            certRequest.contact.jobTitle  = productInfo.ProductParameters["JobTitle"];
            certRequest.contact.email     = productInfo.ProductParameters["Email"];
            certRequest.contact.nameFirst = productInfo.ProductParameters["FirstName"];
            certRequest.contact.nameLast  = productInfo.ProductParameters["LastName"];
            certRequest.contact.phone     = productInfo.ProductParameters["Phone"];

            certRequest.organization                  = new OrganizationInfo();
            certRequest.organization.address          = new AddressInfo();
            certRequest.organization.address.address1 = productInfo.ProductParameters["OrganizationAddress"];
            certRequest.organization.address.city     = productInfo.ProductParameters["OrganizationCity"];
            certRequest.organization.address.state    = productInfo.ProductParameters["OrganizationState"];
            certRequest.organization.address.country  = productInfo.ProductParameters["OrganizationCountry"];
            certRequest.organization.name             = productInfo.ProductParameters["OrganizationName"];
            certRequest.organization.phone            = productInfo.ProductParameters["OrganizationPhone"];

            certRequest.organization.jurisdictionOfIncorporation         = new JurisdictionInfo();
            certRequest.organization.jurisdictionOfIncorporation.state   = productInfo.ProductParameters["JurisdictionState"];
            certRequest.organization.jurisdictionOfIncorporation.country = productInfo.ProductParameters["JurisdictionCountry"];
            certRequest.organization.registrationNumber = productInfo.ProductParameters["RegistrationNumber"];

            certRequest.SetCSR(csr);

            certRequest.period      = Convert.ToInt32(productInfo.ProductParameters["CertificatePeriodInYears"]);
            certRequest.productType = productInfo.ProductID;
            certRequest.rootType    = _rootType;
            certRequest.slotSize    = productInfo.ProductParameters.Keys.Contains("SlotSize") ? productInfo.ProductParameters["SlotSize"] : "FIVE";

            List <string> sans = new List <string>();

            foreach (string[] sanValues in san.Values)
            {
                foreach (string sanValue in sanValues)
                {
                    sans.Add(sanValue);
                }
            }
            certRequest.subjectAlternativeNames = sans.ToArray();

            string response = _api.EnrollCSR(csr, certRequest);

            return(JsonConvert.DeserializeObject <POSTCertificateEnrollmentResponse>(response));
        }
Example #3
0
        private POSTCertificateEnrollmentResponse RenewReissue(string certificateId, EnrollmentProductInfo productInfo, string csr, Dictionary <string, string[]> san, bool isRenew)
        {
            POSTCertificateRenewalRequest certRequest = new POSTCertificateRenewalRequest();

            certRequest.SetCSR(csr);
            certRequest.rootType = _rootType;


            List <string> sans = new List <string>();

            foreach (string[] sanValues in san.Values)
            {
                foreach (string sanValue in sanValues)
                {
                    sans.Add(sanValue);
                }
            }
            certRequest.subjectAlternativeNames = sans.ToArray();

            string response = _api.RenewReissueCSR(certificateId, csr, certRequest, isRenew);

            return(JsonConvert.DeserializeObject <POSTCertificateEnrollmentResponse>(response));
        }
Example #4
0
        public override void ValidateProductInfo(EnrollmentProductInfo productInfo, Dictionary <string, object> connectionInfo)
        {
            Logger.MethodEntry(ILogExtensions.MethodLogLevel.Debug);

            Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);
        }
Example #5
0
        public override EnrollmentResult Enroll(ICertificateDataReader certificateDataReader, string csr, string subject, Dictionary <string, string[]> san, EnrollmentProductInfo productInfo, CSS.PKI.PKIConstants.X509.RequestFormat requestFormat, RequestUtilities.EnrollmentType enrollmentType)
        {
            Logger.MethodEntry(ILogExtensions.MethodLogLevel.Debug);

            foreach (KeyValuePair <string, string> configEntry in productInfo.ProductParameters)
            {
                Logger.Trace($"{configEntry.Key}: {configEntry.Value}");
            }

            string[][] parameterKeys = new string[][] { };
            if (enrollmentType == RequestUtilities.EnrollmentType.New)
            {
                parameterKeys = new string[][] { new string[] { "Email", "string" },
                                                 new string[] { "FirstName", "string" },
                                                 new string[] { "LastName", "string" },
                                                 new string[] { "Phone", "string" },
                                                 new string[] { "CertificatePeriodInYears", "int" } }
            }
            ;
            else
            {
                parameterKeys = new string[][] { new string[] { "PriorCertSN", "string" } }
            };

            ValidateParameters <string>(productInfo.ProductParameters, parameterKeys);

            POSTCertificateEnrollmentResponse enrollmentResponse = new POSTCertificateEnrollmentResponse();

            try
            {
                switch (enrollmentType)
                {
                case RequestUtilities.EnrollmentType.New:
                    switch (productInfo.ProductID)
                    {
                    case "DV_SSL":
                    case "DV_WILDCARD_SSL":
                    case "UCC_DV_SSL":
                        enrollmentResponse = EnrollDV(productInfo, csr, san);
                        break;

                    case "OV_SSL":
                    case "OV_CS":
                    case "OV_DS":
                    case "OV_WILDCARD_SSL":
                    case "UCC_OV_SSL":
                        enrollmentResponse = EnrollOV(productInfo, csr, san);
                        break;

                    case "EV_SSL":
                    case "UCC_EV_SSL":
                        enrollmentResponse = EnrollEV(productInfo, csr, san);
                        break;

                    default:
                        return(new EnrollmentResult {
                            Status = 30, StatusMessage = $"Error attempting to enroll certificate {subject}: Invalid Product ID - {productInfo.ProductID}."
                        });
                    }

                    break;

                case RequestUtilities.EnrollmentType.Renew:
                case RequestUtilities.EnrollmentType.Reissue:
                    CAConnectorCertificate certificate = certificateDataReader.GetCertificateRecord(DataConversion.HexToBytes(productInfo.ProductParameters["PriorCertSN"]));
                    enrollmentResponse = RenewReissue(certificate.CARequestID, productInfo, csr, san, enrollmentType == RequestUtilities.EnrollmentType.Renew);
                    break;

                default:
                    return(new EnrollmentResult {
                        Status = 30, StatusMessage = $"Unsupported EnrollmentType: {enrollmentType}"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new EnrollmentResult {
                    Status = 30, StatusMessage = $"Error attempting to enroll certificate {subject}: {ex.Message}."
                });
            }

            EnrollmentResult result = new EnrollmentResult();

            CertificateStatusEnum certStatus = CertificateStatusEnum.PENDING_ISSUANCE;

            for (int i = 0; i < _enrollmentRetries; i++)
            {
                try
                {
                    GETCertificateDetailsResponse certResponse = JsonConvert.DeserializeObject <GETCertificateDetailsResponse>(_api.GetCertificate(enrollmentResponse.certificateId));
                    Enum.TryParse(certResponse.status, out certStatus);
                    if (certStatus == CertificateStatusEnum.ISSUED)
                    {
                        break;
                    }
                }
                catch (Exception) { }

                Thread.Sleep(_secondsBetweenEnrollmentRetries * 1000);
            }

            string pemCertificate = certStatus == CertificateStatusEnum.ISSUED ? RemovePEMHeader(JsonConvert.DeserializeObject <GETCertificateResponse>(_api.DownloadCertificate(enrollmentResponse.certificateId)).pems.certificate) : string.Empty;

            Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);

            return(new EnrollmentResult {
                CARequestID = enrollmentResponse.certificateId,
                Certificate = pemCertificate,
                Status = APIProcessor.MapReturnStatus(certStatus),
                StatusMessage = $"GoDaddy Status = {certStatus.ToString()}"
            });
        }
Example #6
0
        public override EnrollmentResult Enroll(string csr, string subject, Dictionary <string, string[]> san, EnrollmentProductInfo productInfo, CSS.PKI.PKIConstants.X509.RequestFormat requestFormat, RequestUtilities.EnrollmentType enrollmentType)
        {
            Logger.MethodEntry(ILogExtensions.MethodLogLevel.Debug);

            Logger.MethodExit(ILogExtensions.MethodLogLevel.Debug);

            throw new NotImplementedException();
        }