【问题标题】:A call to SSPI failed while sending email using amazon ses from windows application使用 amazon ses 从 Windows 应用程序发送电子邮件时调用 SSPI 失败
【发布时间】:2013-07-25 21:11:16
【问题描述】:

我正在使用 amazon ses 发送电子邮件,并且我在网站和 Windows 应用程序中使用相同的配置。
该网站正在正常发送电子邮件,但 Windows 应用程序给了我这个错误,而不是发送电子邮件:

请注意,当我将 Windows 应用程序中的 smtp 配置更改为 gmail 之类的东西时,它工作正常,问题发生在亚马逊 ses 上,并且就在今天开始发生,然后 ses 在 Windows 应用程序上工作正常。
另请注意,网站和 Windows 应用程序现在都在本地运行。

堆栈跟踪:

   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.TlsStream.CallProcessAuthentication(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Mail.SmtpConnection.Flush()
   at System.Net.Mail.ReadLinesCommand.Send(SmtpConnection conn)
   at System.Net.Mail.EHelloCommand.Send(SmtpConnection conn, String domain)
   at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
   at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
   at System.Net.Mail.SmtpClient.GetConnection()
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at Mail.EmailSender.SendMail(MailMessage mail) in e:\Mail\EmailSender.cs:line 175

内部异常:

{"The message received was unexpected or badly formatted"}

【问题讨论】:

  • 您能发布内部异常详细信息和/或完整堆栈跟踪吗?
  • 在您的 Windows 应用程序运行的机器上,您是否有任何防火墙规则阻止出站连接?
  • 可能是,但我在同一台机器上的另一个 win 应用程序中使用相同的配置,一切正常。
  • 对不起,如果我有点分歧,但您是否尝试过从另一台机器或另一个网络运行此应用程序?
  • 同一个应用程序现在不能在其他机器上运行,但是具有相同 smtp 配置的其他应用程序即使在同一台机器上也能正常运行

标签: c# asp.net security smtp amazon-ses


【解决方案1】:

我遇到了同样的问题,最终归结为尝试连接时生效的 SecurityProtocol。

添加

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

在 client.Send 为我解决之前(我们在其他地方将其更改为 Ssl3 以与不同的服务通信) .

我不知道这是 SES 的“功能”还是我只是假设魔法应该起作用,但您可以在这里看到一些历史: https://forums.aws.amazon.com/thread.jspa?messageID=472516

【讨论】:

    【解决方案2】:

    尝试检查您的 SPN (ServicePrincipalName) 配置。这个问题听起来像是在您的配置中某处发生了损坏或修改。如果服务实例的登录帐户发生变化,则必须在新帐户下重新注册 SPN。

    【讨论】:

    【解决方案3】:

    看看this SO post,网上很多人都指出证书是问题所在,我想知道您使用的“验证”文件是否实际上是错误的;他们通过用 .p12 替换“.pem 文件”解决了这个问题

    还可以看看这个MS Hotfix,这听起来很像你的问题。

    正如 FeliceM 所暗示的,这可能是一个帐户问题:(取自)

    " Aspnet 在不同的帐户下运行,因此您必须使用 WinHttpCertCfg.exe 工具来允许以下帐户访问您应该安装在本地计算机个人/受信任文件夹中的证书..

    ASPNET 网络服务认证用户

    例如

    winhttpcertcfg -g -c LOCAL_MACHINE\MY -s "CertificateName" -a "ASPNET"

    其中证书名称是您的证书的友好名称。

    您可以从以下链接获取工具和信息:

    http://msdn.microsoft.com/en-us/library/aa384088%28VS.85%29.aspx#%5Fusing

    "

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      相关资源
      最近更新 更多