2013-06-20 196 views
6

我使用SharpSVN,並向顛覆中添加一個文件夾。然後我嘗試提交它,我得到這個異常:SharpSVN - 服務器證書驗證失敗

SharpSvn.SvnRepositoryIOException: OPTIONS of 'https://sth.com/svn/blah/Documents': Server certificate verification failed: certificate has expired, certificate issued for a different hostname, issuer is not trusted

至於我在這裏看到: Server certificate verification failed

..它看來,我必須使用--trust-server-cert的選擇,但我不你可以在SvnCommitArgs的論點中看到這個地方。

另外,我還發現這一點: How do I use a custom Certificate Authority in SharpSvn without installing the certificate

..where我看到這一點:

client.Configuration.SetOption(...) 

但我不知道我必須提供使其承諾沒有問題什麼設置。

有沒有人做過類似的事情?

編輯: 我也試着這樣做:

client.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers); 

    void Authentication_SslServerTrustHandlers(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) 
    { 
     // Accept ceritificate here? 
    } 

但我不明白我必須在處理器中做接受證書... :(

回答

10

OK 。我解決了這個問題,現在我得到一個其它的錯誤 你需要做的是這樣的:

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 
    } 
+1

確保你還看「E」的另一個論點和檢查。這允許*所有* SSL證書(也過期,撤銷等) –