如何在本地Windows计算机上从AWS Certificate Manger导出和使用私有证书?
当我卷曲部署到AWS Fargate的服务时,我从Powershell得到以下输出。
curl : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ curl https://mydomain-myservice.aws ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest],WebExceptio
n
+ FullyQualifiedErrorId : WebcmdletwebresponseException,microsoft.PowerShell.Commands.InvokeWebRequestCommand
该错误是由于未在我的计算机上安装证书颁发机构引起的。我知道Powershell有许多方法可以忽略或跳过证书检查,但是我想实际安装证书。另外,该服务肯定能正常工作,因为我可以使用Postman进行GET和POST,然后用浏览器和curl来打它(如果我忽略证书)。
我尝试过的一些步骤
因此,我在AWS Certificate Manager中拥有一个私有证书。我已经导出了三个文件,并将它们保存到本地Windows机器中
Certificate.txt
Certificate_chain.txt
private_key.txt
我尝试通过将microsoft certmgr添加到“受信任的根证书颁发机构”目录中来安装证书,但这没用。
还尝试使用certutil实用程序从Powershell添加证书,但这没有用。
最后,我一直在尝试直接将Powershell与证书一起使用。
wget -Uri "https://mydomain-myservice.aws/healthcheck" -met
hod "Get" -Certificate .\Certificate_chain.txt
哪个发生了以下错误
Invoke-WebRequest : Cannot bind parameter 'Certificate'. Cannot convert value ".\Certificate_chain.txt" to type
"system.security.Cryptography.X509Certificates.X509Certificate". Error: "The system cannot find the file specified.
"
At line:1 char:134
+ ... t.net/healthcheck" -method "Get" -Certificate .\Certificate_chain.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest],ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,microsoft.PowerShell.Commands.InvokeWebRequestCommand
看到该错误后,我已经安装了OpenSSL并尝试转换我的证书文件,但未成功。