[問題] ssl stream client authentication
請問關於c#中的ssl socket要用sslstream這個class來實現
我做client端這邊,因為client/server certificate跟CA certificate都是自己簽的
ValidateServerCertificate這個call back中我加入了:
if (chain.ChainStatus.Length == 1)
{
if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors
|| certificate.Subject == certificate.Issuer)
{
if (chain.ChainStatus[0].Status ==
X509ChainStatusFlags.UntrustedRoot)
{
Console.WriteLine("Server Certificate
from Self-signed root CA");
return true;
}
}
}
跳過了自己簽發憑證的檢查問題,server端我是要求要驗證用戶端(python server)
所以在c# client自己要驗證自己這邊卡住
try
{
sslStream.AuthenticateAsClient("servername", certs,
SslProtocols.Ssl3, true);
}
請問我要怎麼讓我的client certificate可以過的了關呢?
我不知道我該怎麼設定我自己簽發的CA去讓程式自己檢查
certs我是這樣設定的,把自己簽的client certtificate加入collection中:
clientCertificate = X509Certificate.CreateFromCertFile("C:/myclient.crt");
X509CertificateCollection certs = new X509CertificateCollection();
certs.Add(clientCertificate);
然後就套用AuthenticateAsClient...
麻煩知道的人可以給我點tip嗎?
感謝大家~~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.216.101
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章