簡體   English   中英

如何在SharpSvn中使用自定義證書頒發機構而不安裝證書

[英]How do I use a custom Certificate Authority in SharpSvn without installing the certificate

我正在嘗試使用SharpSvn訪問一個Subversion版本庫。 僅可通過https訪問該存儲庫,並且該計算機使用其自己的私有證書頒發機構(不必擔心此處的安全性,我信任該頒發機構)。

我擁有證書頒發機構的公共根證書,但是由於用戶訪問權限,我無法將證書安裝到證書存儲中。

如果直接使用subversion,則可以添加:

servers:global:ssl-authority-files=/path/to/cacert.crt
servers:groups:myhost=myhostsdns.com

作為命令行對象或配置文件。

如何在SharpSvn中設置這些選項,以便可以使用cacert.crt文件,以便在嘗試訪問存儲庫時不會出現“證書驗證失敗”的消息,而不必忽略該錯誤?

非常感謝

只有問了問題才意識到答案是怎么回事?

我通過在SvnClient對象上設置配置選項來解決此問題:

SvnClient _svnClient = new SvnClient();
_svnClient.Configuration.SetOption("servers", "global", "ssl-authority-files", "/path/to/cacert.crt");
_svnClient.Configuration.SetOption("servers", "groups", "myhost", "myhostsdns.com");

對自助表示歉意,希望對下一個人有所幫助。

擴展對Bert Huijben的評論(上):

client.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers);
void Authentication_SslServerTrustHandlers(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e)
{
    // Look at the rest of the arguments of E, whether you wish to accept

    // If accept:
    e.AcceptedFailures = e.Failures;
    e.Save = true; // Save acceptance to authentication store
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM