【问题标题】:ASP.NET Core + Amazon SES: The remote certificate is invalid according to the validation procedureASP.NET Core + Amazon SES:远程证书根据验证程序无效
【发布时间】:2017-01-09 14:54:26
【问题描述】:

我正在尝试使用 ASP.NET Core、MailKit 和 Amazon SES 发送电子邮件:

  using (SmtpClient client = new SmtpClient(new ProtocolLogger("smtp.log"))) {
      client.Connect("email-smtp.us-east-1.amazonaws.com", 587, SecureSocketOptions.StartTls);
      client.Authenticate("myusername", "mypassword");
      await client.SendAsync(message);
      client.Disconnect(true);
  }

我不断收到错误消息“根据验证程序,远程证书无效。”。

日志文件显示:

Connected to smtp://email-smtp.us-east-1.amazonaws.com:587/?starttls=always
S: 220 email-smtp.amazonaws.com ESMTP SimpleEmailService-1737464811 qt5bXhIgVseJaHPspjp4
C: EHLO [127.0.0.1]
S: 250-email-smtp.amazonaws.com
S: 250-8BITMIME
S: 250-SIZE 10485760
S: 250-STARTTLS
S: 250-AUTH PLAIN LOGIN
S: 250 Ok
C: STARTTLS
S: 220 Ready to start TLS

我错过了什么?

【问题讨论】:

    标签: amazon-web-services asp.net-core amazon-ses mailkit


    【解决方案1】:

    您需要提供自己的client.ServerCertificateValidationCallback 方法来验证服务器证书。它可以像始终返回 true 一样简单,也可以根据服务器的已知指纹或任何其他可能性检查指纹。

    欲了解更多信息,请参阅http://www.mimekit.org/docs/html/P_MailKit_MailService_ServerCertificateValidationCallback.htm

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-19
      • 2011-03-28
      • 2016-11-28
      • 2020-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多