C# と VB.NET の質問掲示板

わんくま同盟

ASP.NET、C++/CLI、Java 何でもどうぞ

C# と VB.NET の入門サイト


(過去ログ 162 を表示中)
■93686 / )  Re[2]: 「SSL証明書の検証を無視させる」はなぜ必要ですか?
□投稿者/ 白熊 (2回)-(2020/01/10(Fri) 10:12:46)
Azulean様
ご教授ありがとうございます。

>
>>また、Connect()メソッドでuseSsl=trueであっても必要なのでしょうか?
>
> 逆です。
> useSsl = true だからこそ必要です。



まずPOP3サーバーでポートは110を指定し、SSL認証は使用していません。useSslはfalseです。
この状態でuseSslにfalseを指定してConnectを実行すると例外が発生します。

pop3.Connect("xxxxx", 110, useSsl:false);
例外内容
MailKit.Security.SslHandshakeException
An error occurred while attempting to establish an SSL or TLS connection.

The SSL certificate presented by the server is not trusted by the system for one or more of the following reasons:
1. The server is using a self-signed certificate which cannot be verified.
2. The local system is missing a Root or Intermediate certificate needed to verify the server's certificate.
3. The certificate presented by the server is expired or invalid.

See https://github.com/jstedfast/MailKit/blob/master/FAQ.md#InvalidSslCertificate for possible solutions.


次に、証明書を無視するコードを記載し実行するとメールを受信することができました。
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
pop3.Connect("xxxxx", 110, useSsl:false);


どうしてuseSsl=falseなのにSSL認証をチェックしようとするのでしょうか?
返信 編集キー/


管理者用

- Child Tree -