2017-04-21 76 views
1

我有在Ubuntu 16.04.2 LTS上運行的Mono(版本4.2.1)代碼;該代碼嘗試使用Amazon SES發送電子郵件並失敗。我從其他搜索中瞭解到,錯誤是由於證書沒有出現在mono的信任存儲中。該命令以修正此之中: mozroots --import --ask-除去如何讓我的Mono 4.2代碼通過Amazon SES發送電子郵件?

後跟:

certmgr -ssl SMTPS://email-smtp.eu-west-1.amazonaws.com:587

(因爲email-smtp.eu-west-1.amazonaws.com是我使用的SMTP服務器;在端口587)

第一個命令工作正常,進口162個證書來我的商店。 第二個命令失敗並出現異常。我究竟做錯了什麼?

這裏的堆棧跟蹤:

Unhandled Exception: 
System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed. 
    at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (IAsyncResult asyncResult) <0x402e7020 + 0x00132> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (IAsyncResult ar, Boolean ignoreEmpty) <0x402e6f50 + 0x00031> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (IAsyncResult result) <0x402e3aa0 + 0x00225> in <filename unknown>:0 
    --- End of inner exception stack trace --- 
    at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (IAsyncResult result) <0x402e7cf0 + 0x000ec> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x402e7a40 + 0x0007f> in <filename unknown>:0 
    --- End of inner exception stack trace --- 
    at Mono.Security.Protocol.Tls.SslStreamBase.EndNegotiateHandshake (Mono.Security.Protocol.Tls.InternalAsyncResult asyncResult) <0x402e1190 + 0x0007b> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslStreamBase.NegotiateHandshake() <0x402da8b0 + 0x000b6> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslStreamBase.Write (System.Byte[] buffer, Int32 offset, Int32 count) <0x402da4d0 + 0x000af> in <filename unknown>:0 
    at System.IO.StreamWriter.Flush (Boolean flushStream, Boolean flushEncoder) <0x7f07ce354da0 + 0x000fa> in <filename unknown>:0 
    at System.IO.StreamWriter.Flush() <0x7f07ce354d70 + 0x0001f> in <filename unknown>:0 
    at Mono.Tools.CertificateManager.GetCertificatesFromSslSession (System.String url) <0x402a43e0 + 0x00357> in <filename unknown>:0 
    at Mono.Tools.CertificateManager.Ssl (System.String host, Boolean machine, Boolean verbose) <0x402a39f0 + 0x0013a> in <filename unknown>:0 
    at Mono.Tools.CertificateManager.Main (System.String[] args) <0x4029ed70 + 0x004f0> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed. 
    at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (IAsyncResult asyncResult) <0x402e7020 + 0x00132> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (IAsyncResult ar, Boolean ignoreEmpty) <0x402e6f50 + 0x00031> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (IAsyncResult result) <0x402e3aa0 + 0x00225> in <filename unknown>:0 
    --- End of inner exception stack trace --- 
    at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (IAsyncResult result) <0x402e7cf0 + 0x000ec> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x402e7a40 + 0x0007f> in <filename unknown>:0 
    --- End of inner exception stack trace --- 
    at Mono.Security.Protocol.Tls.SslStreamBase.EndNegotiateHandshake (Mono.Security.Protocol.Tls.InternalAsyncResult asyncResult) <0x402e1190 + 0x0007b> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslStreamBase.NegotiateHandshake() <0x402da8b0 + 0x000b6> in <filename unknown>:0 
    at Mono.Security.Protocol.Tls.SslStreamBase.Write (System.Byte[] buffer, Int32 offset, Int32 count) <0x402da4d0 + 0x000af> in <filename unknown>:0 
    at System.IO.StreamWriter.Flush (Boolean flushStream, Boolean flushEncoder) <0x7f07ce354da0 + 0x000fa> in <filename unknown>:0 
    at System.IO.StreamWriter.Flush() <0x7f07ce354d70 + 0x0001f> in <filename unknown>:0 
    at Mono.Tools.CertificateManager.GetCertificatesFromSslSession (System.String url) <0x402a43e0 + 0x00357> in <filename unknown>:0 
    at Mono.Tools.CertificateManager.Ssl (System.String host, Boolean machine, Boolean verbose) <0x402a39f0 + 0x0013a> in <filename unknown>:0 
    at Mono.Tools.CertificateManager.Main (System.String[] args) <0x4029ed70 + 0x004f0> in <filename unknown>:0 

回答

0

一個certmgr常見故障的不與sudo運行它。它產生了Exception,這是一個非常誤導。

在MacOS/Linux的:

certmgr -ssl smtps://email-smtp.eu-west-1.amazonaws.com:587 

會產生您發佈確切的錯誤。

使用sudo:

sudo certmgr -ssl smtps://email-smtp.eu-west-1.amazonaws.com:587 

結果:

X.509 Certificate v3 
    Issued from: C=US, O=Equifax, OU=Equifax Secure Certificate Authority 
    Issued to: C=US, O=GeoTrust Inc., CN=GeoTrust Global CA 
    Valid from: 5/21/2002 4:00:00 AM 
    Valid until: 8/21/2018 4:00:00 AM 
    *** WARNING: Certificate signature is INVALID *** 
Import this certificate into the CA store ?yes 

X.509 Certificate v3 
    Issued from: C=US, O=GeoTrust Inc., CN=GeoTrust Global CA 
    Issued to: C=US, O=Google Inc, CN=Google Internet Authority G2 
    Valid from: 4/1/2015 12:00:00 AM 
    Valid until: 12/31/2017 11:59:59 PM 
    *** WARNING: Certificate signature is INVALID *** 
Import this certificate into the CA store ?yes 

X.509 Certificate v3 
    Issued from: C=US, O=Google Inc, CN=Google Internet Authority G2 
    Issued to: C=US, S=California, L=Mountain View, O=Google Inc, CN=smtp.gmail.com 
    Valid from: 4/12/2017 1:28:00 PM 
    Valid until: 7/5/2017 1:28:00 PM 
Import this certificate into the AddressBook store ?yes 

3 certificates added to the stores. 

注意:確保你所回答yes的進口問題。

+0

我試着用sudo運行它,並得到了完全相同的錯誤。我的第一次嘗試(沒有sudo)可能會損壞系統中的某些東西嗎?那麼我將如何回滾這些變化? – Cois

+0

@Cois不,它不應該搞砸了......我只是試了一遍,沒有sudo同樣的錯誤,與sudo我得到3證書報告,並且他們已經在CA商店... – SushiHangover

+1

@ Cois個人而言,爲了添加TLS 1.1/1.2支持,我將添加Google的BoringSSL以取代託管提供商,因此我將升級到mono 4.8。遠離託管提供商消除了很多問題,並且因爲使用了系統證書存儲區而不再需要使用mozroots ...亞馬遜仍然在其smtp服務器上支持tls1.0/1.0(至少現在),因此單聲道4.2 * should * work .... – SushiHangover

相關問題