Exemple #1
0
 private Amazon.ACMPCA.Model.IssueCertificateResponse CallAWSServiceOperation(IAmazonACMPCA client, Amazon.ACMPCA.Model.IssueCertificateRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Certificate Manager Private Certificate Authority", "IssueCertificate");
     try
     {
         #if DESKTOP
         return(client.IssueCertificate(request));
         #elif CORECLR
         return(client.IssueCertificateAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Exemple #2
0
        public object Execute(ExecutorContext context)
        {
            System.IO.MemoryStream _CsrStream = null;

            try
            {
                var cmdletContext = context as CmdletContext;
                // create request
                var request = new Amazon.ACMPCA.Model.IssueCertificateRequest();

                if (cmdletContext.CertificateAuthorityArn != null)
                {
                    request.CertificateAuthorityArn = cmdletContext.CertificateAuthorityArn;
                }
                if (cmdletContext.Csr != null)
                {
                    _CsrStream  = new System.IO.MemoryStream(cmdletContext.Csr);
                    request.Csr = _CsrStream;
                }
                if (cmdletContext.IdempotencyToken != null)
                {
                    request.IdempotencyToken = cmdletContext.IdempotencyToken;
                }
                if (cmdletContext.SigningAlgorithm != null)
                {
                    request.SigningAlgorithm = cmdletContext.SigningAlgorithm;
                }
                if (cmdletContext.TemplateArn != null)
                {
                    request.TemplateArn = cmdletContext.TemplateArn;
                }
                if (cmdletContext.Validity != null)
                {
                    request.Validity = cmdletContext.Validity;
                }

                CmdletOutput output;

                // issue call
                var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);
                try
                {
                    var    response       = CallAWSServiceOperation(client, request);
                    object pipelineOutput = null;
                    pipelineOutput = cmdletContext.Select(response, this);
                    output         = new CmdletOutput
                    {
                        PipelineOutput  = pipelineOutput,
                        ServiceResponse = response
                    };
                }
                catch (Exception e)
                {
                    output = new CmdletOutput {
                        ErrorResponse = e
                    };
                }

                return(output);
            }
            finally
            {
                if (_CsrStream != null)
                {
                    _CsrStream.Dispose();
                }
            }
        }