public NodeId StartNewKeyPairRequest( NodeId applicationId, NodeId certificateGroupId, NodeId certificateTypeId, string subjectName, string[] domainNames, string privateKeyFormat, string privateKeyPassword, string authorityId) { Guid id = GetNodeIdGuid(applicationId); lock (Lock) { var application = (from x in Applications where x.ApplicationId == id select x).SingleOrDefault(); if (application == null) { throw new ServiceResultException(StatusCodes.BadNodeIdUnknown); } var request = (from x in CertificateRequests where x.AuthorityId == authorityId && x.ApplicationId == id select x).SingleOrDefault(); bool isNew = false; if (request == null) { request = new CertificateRequest() { RequestId = Guid.NewGuid(), AuthorityId = authorityId }; isNew = true; } request.State = (int)CertificateRequestState.New; request.CertificateGroupId = certificateGroupId; request.CertificateTypeId = certificateTypeId; request.SubjectName = subjectName; request.DomainNames = domainNames; request.PrivateKeyFormat = privateKeyFormat; request.PrivateKeyPassword = privateKeyPassword; request.CertificateSigningRequest = null; request.ApplicationId = id; if (isNew) { CertificateRequests.Add(request); } SaveChanges(); return(new NodeId(request.RequestId, NamespaceIndex)); } }
public override NodeId CreateCertificateRequest( NodeId applicationId, byte[] certificate, byte[] privateKey, string authorityId) { Guid id = GetNodeIdGuid(applicationId); lock (Lock) { var application = (from x in Applications where x.ApplicationId == id select x).SingleOrDefault(); if (application == null) { throw new ServiceResultException(StatusCodes.BadNodeIdUnknown); } var request = (from x in CertificateRequests where x.AuthorityId == authorityId && x.ApplicationId == id select x).SingleOrDefault(); bool isNew = false; if (request == null) { request = new CertificateRequest() { RequestId = Guid.NewGuid(), AuthorityId = authorityId }; isNew = true; } request.State = (int)CertificateRequestState.New; request.Certificate = certificate; request.PrivateKey = privateKey; request.ApplicationId = id; if (isNew) { CertificateRequests.Add(request); } SaveChanges(); return(new NodeId(request.RequestId, NamespaceIndex)); } }