2017-04-10 36 views

回答

0

可以使用Let's Encrypt證書使WCF服務通過https進行通信。您可以使用letsencrypt.org網站上列出的某個Windows客戶端進行設置。
如果您決定使用ACMESharp client,您會注意到一個基本功能尚未完全實現:certificate renewal
但是,這個問題可以通過使用由Marc Durdin提供的腳本來解決,他提交了on his blog
設置完ACMESharp客戶端並在腳本中定義變量後,必須創建一個計劃任務,該任務每60天運行一次並執行該腳本。

要使WCF服務使用https綁定,您必須在服務的配置中定義該綁定。
創建一個security元素。然後,參考endpoint elementbindingConfiguration屬性中的父代binding元素的name屬性。在同一個endpoint元素的address屬性中,您必須指定您的服務可用的HTTPS地址。
如果使用不同於443的端口,則必須像這樣明確定義它:https://hostname.tld:port/ServiceName/

完成所有設置後,您必須將由letsencrypt提供的證書綁定到該綁定。您可以使用netsh http add sslcert命令執行此操作。我寫了下面的腳本,你可以用它來自動執行此過程中結合證書上面提到的更新:如果定義腳本變量

$domain = 'hostname.tld' # insert your hostname 
$ipport = '0.0.0.0:portnumber' # insert the proper binding 
$getThumb = Get-ChildItem -path cert:\LocalMachine\My | where { $_.Subject -match $domain } 
$certHash = $getThumb.Thumbprint 
$activeBinding = netsh http show sslcert ipport=$ipport 
$activeBindingHash = $activeBinding[5] 
$guid = '{' + [guid]::NewGuid() + '}' 
If(-Not $activeBindingHash) 
{ 
    netsh http add sslcert ipport=$ipport certhash=$certHash appid=$guid 
    return 
} 
$hashesMatch = $activeBindingHash | Select-String -Pattern $certHash -Quiet 
If(-Not $hashesMatch) 
{ 
    netsh http delete sslcert ipport=$ipport 
    netsh http add sslcert ipport=$ipport certhash=$certHash appid=$guid  
} 

,並運行一個計劃任務過多,你WCF服務將使用來自Let's Encrypt的ssl證書,該證書將自動更新和反彈。

相關問題