Ejemplo n.º 1
0
        public async Task <string> CreateNewKeyPairRequestAsync([FromBody] CreateNewKeyPairRequestApiModel newKeyPairRequest)
        {
            if (newKeyPairRequest == null)
            {
                throw new ArgumentNullException(nameof(newKeyPairRequest));
            }
            string authorityId = User.Identity.Name;

            return(await _certificateRequest.StartNewKeyPairRequestAsync(
                       newKeyPairRequest.ApplicationId,
                       newKeyPairRequest.CertificateGroupId,
                       newKeyPairRequest.CertificateTypeId,
                       newKeyPairRequest.SubjectName,
                       newKeyPairRequest.DomainNames,
                       newKeyPairRequest.PrivateKeyFormat,
                       newKeyPairRequest.PrivateKeyPassword,
                       authorityId));
        }
Ejemplo n.º 2
0
        private async Task NewKeyPairRequestAllApplications()
        {
            Skip.If(!_fixture.RegistrationOk);
            int count = 0;

            foreach (var application in _applicationTestSet)
            {
                string[] groups = await _certificateGroup.GetCertificateGroupIds();

                foreach (var group in groups)
                {
                    var    applicationId = application.Model.ApplicationId.ToString();
                    string requestId     = await _certificateRequest.StartNewKeyPairRequestAsync(
                        applicationId,
                        group,
                        null,
                        application.Subject,
                        application.DomainNames.ToArray(),
                        application.PrivateKeyFormat,
                        application.PrivateKeyPassword,
                        "*****@*****.**");

                    Assert.NotNull(requestId);
                    // read request
                    var request = await _certificateRequest.ReadAsync(requestId);

                    Assert.Equal(CertificateRequestState.New, request.State);
                    Assert.Equal(requestId, request.RequestId);
                    Assert.Equal(applicationId, request.ApplicationId);
                    Assert.False(request.SigningRequest);
                    Assert.True(Opc.Ua.Utils.CompareDistinguishedName(application.Subject, request.SubjectName));
                    Assert.Equal(group, request.CertificateGroupId);
                    //Assert.Equal(null, fullRequest.CertificateTypeId);
                    Assert.Equal(application.DomainNames.ToArray(), request.DomainNames);
                    Assert.Equal(application.PrivateKeyFormat, request.PrivateKeyFormat);

                    // TODO: test all fields
                    application.RequestIds.Add(requestId);
                    count++;
                }
            }
            Assert.True(count > 0);
        }