我使用VSTS使用installation和install任务部署asp.net网站,但是,我正在研究如何自动化站点SSL证书的安装和配置,以便在将站点部署到主机上之前不必手动安装ssl证书。
我正在考虑使用以下方法。
1)在vs解决方案中包括ssl证书。
2)部署ssl证书作为站点部署的一部分,并使用远程powershell任务运行'CertMgr‘,在本地机器个人证书存储中安装证书。
在理想的情况下,我希望将SSL证书作为VSTS中的部署定义的一部分,但是我看不到有这样的选项吗?在进行VS解决方案路由之前,是否可以配置VSTS部署任务,以便在远程目标计算机上下载和安装SSL证书?
发布于 2018-03-23 07:44:26
没有可以下载和安装证书的内置任务。您可以将其添加到源代码管理或其他服务器(例如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()
相关问题:Visual studio team services deploymen/buildt certificate error
https://stackoverflow.com/questions/49428317
复制相似问题