/// <summary>
 /// Create services
 /// </summary>
 /// <param name="serializer"></param>
 /// <param name="workflow"></param>
 /// <param name="issuer"></param>
 public KeyPairRequestHandler(IKeyHandleSerializer serializer,
                              IRequestWorkflow workflow, ICertificateIssuer issuer)
 {
     _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _issuer     = issuer ?? throw new ArgumentNullException(nameof(issuer));
     _workflow   = workflow ?? throw new ArgumentNullException(nameof(workflow));
 }
        /// <summary>
        /// Create certificate request
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="serializer"></param>
        /// <param name="entities"></param>
        /// <param name="broker"></param>
        /// <param name="repo"></param>
        /// <param name="logger"></param>
        public KeyPairRequestProcessor(IRequestRepository repo, IKeyStore keys,
            IKeyHandleSerializer serializer, IEntityInfoResolver entities,
            ICertificateRequestEventBroker broker, ILogger logger) {

            _keys = keys ?? throw new ArgumentNullException(nameof(keys));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            _repo = repo ?? throw new ArgumentNullException(nameof(repo));
            _broker = broker ?? throw new ArgumentNullException(nameof(broker));
            _entities = entities ?? throw new ArgumentNullException(nameof(entities));
            _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
        }
Пример #3
0
 /// <summary>
 /// Create database
 /// </summary>
 /// <param name="container"></param>
 /// <param name="keys"></param>
 public CertificateDatabase(IItemContainerFactory container,
                            IKeyHandleSerializer keys)
 {
     _certificates = container.OpenAsync("certificates").Result.AsDocuments();
     _keys         = keys ?? throw new ArgumentNullException(nameof(keys));
 }
Пример #4
0
        /// <summary>
        /// Create document
        /// </summary>
        /// <param name="id"></param>
        /// <param name="serializer"></param>
        /// <param name="cert"></param>
        /// <param name="certificateName"></param>
        /// <returns></returns>
        public static CertificateDocument ToDocument(this Certificate cert,
                                                     string certificateName, string id, IKeyHandleSerializer serializer)
        {
            var ski = cert.GetSubjectKeyIdentifierExtension();
            var aki = cert.GetAuthorityKeyIdentifierExtension();
            var san = cert.GetSubjectAltNameExtension();

            return(new CertificateDocument {
                Issuer = cert.Issuer.Name,
                IssuerAltNames = aki?.AuthorityNames,
                IssuerKeyId = aki?.KeyId,
                IssuerSerialNumber = aki?.SerialNumber.ToString(),
                IsIssuer = cert.IsIssuer(),
                IsserPolicies = cert.IssuerPolicies,
                Subject = cert.Subject.Name,
                KeyId = ski?.SubjectKeyIdentifier,
                SubjectAltNames = san?.DomainNames
                                  .Concat(san.IPAddresses)
                                  .ToList(),
                NotAfter = cert.NotAfterUtc,
                NotBefore = cert.NotBeforeUtc,
                RawData = cert.RawData,
                SerialNumber = cert.GetSerialNumberAsString(),
                Thumbprint = cert.Thumbprint,
                DisabledSince = cert.Revoked?.Date,
                Version = DateTime.UtcNow.ToFileTimeUtc(),
                CertificateId = id ?? certificateName,
                CertificateName = certificateName,
                KeyHandle = cert.KeyHandle == null ? null :
                            serializer.SerializeHandle(cert.KeyHandle)
            });
        }