我正在使用 VSTS 使用 IIS Web App Manage 和 IIS Web App Deploy 任务部署一个 asp.net 网站,但我正在寻找方法来自动安装和配置站点 SSL 证书,这样我就不会在主机上部署站点之前,必须手动安装 ssl 证书。
我正在考虑使用以下方法。
1)在vs解决方案中包含ssl证书。
2) 部署 ssl 证书作为站点部署的一部分,并使用远程 powershell 任务运行“CertMgr”以在 localmachines 个人证书存储中安装证书。
在理想的世界中,我希望将 SSL 证书作为部署定义的一部分包含在 VSTS 中,但我看不到此选项?在我走 VS 解决方案路线之前,是否需要配置 VSTS 部署任务以在远程目标计算机上下载并安装 SSL 证书?
没有可以下载和安装证书的内置任务。您可以将其添加到源代码管理或其他服务器(例如 FTP),然后在构建/发布期间下载证书(可以通过 PowerShell 下载文件)。
之后,您可以通过 PowerShell 任务安装证书:
$pfxpath = 'pathtoees.pfx'
$password = 'password'
Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxpath, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($cert)
$store.Close()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句