こんにちは。
台風10号。
空振りに期待。
さて、最近ハマったC#プログラム。
メール送信でエラー。
System.Security.Authentication.AuthenticationException: SSPI への呼び出しに失敗しました。内部例外を参照してください。
場所 System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
場所 System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
場所 System.Net.Security.SslState.ProcessReceivedBlob(Byte buffer, Int32 count, AsyncProtocolRequest asyncRequest)
場所 System.Net.Security.SslState.StartReceiveBlob(Byte buffer, AsyncProtocolRequest asyncRequest)
場所 System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
場所 System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte buffer, AsyncProtocolRequest asyncRequest)
場所 System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
場所 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
場所 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
場所 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
場所 System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
場所 System.Net.TlsStream.Write(Byte buffer, Int32 offset, Int32 size)
場所 System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
場所 System.Net.Mail.SmtpConnection.Flush()
場所 System.Net.Mail.ReadLinesCommand.Send(SmtpConnection conn)
場所 System.Net.Mail.EHelloCommand.Send(SmtpConnection conn, String domain)
場所 System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
場所 System.Net.Mail.SmtpClient.GetConnection()
場所 System.Net.Mail.SmtpClient.Send(MailMessage message)
Security Support Provider Interface (SSPI) は、
Microsoft Windowsにおいてセキュリティに関する様々な機能を提供するAPIである。
ググった結果、TLS1.2 使用するように、
以下のコードを追加したらOK牧場。
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
Amazonメールサーバーは、TLS1.2 じゃないとダメ。
めでたし、めでたし。