smtp4dev icon indicating copy to clipboard operation
smtp4dev copied to clipboard

TLS Mode

Open cdub50 opened this issue 5 years ago • 8 comments

On main and 3.1.2 I am trying to start the container with StartTLS=On using a self signed cert with value of "" but when container is started it shows none for TLS and when I try to send a mail with TLS it throws an error command unrecognized. What is the proper way to enable TLS with a self signed cert?

cdub50 avatar Mar 16 '21 20:03 cdub50

The correct value to use for tlsmode is StartTLS The value StartTLS=On is not valid, but I can see how the docs have lead you to believe this. I will update the docs to make clearer.


From: cdub50 @.> Sent: Tuesday, March 16, 2021 8:44:21 PM To: rnwood/smtp4dev @.> Cc: Subscribed @.***> Subject: [rnwood/smtp4dev] TLS Mode (#659)

On main and 3.1.2 I am trying to start the container with StartTLS=On but when container is started it shows none for TLS and when I try to send a mail with TLS it throws an error command unrecognized. What is the proper way to enable TLS with a self signed cert?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/rnwood/smtp4dev/issues/659, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKEGFYNNTNN53BWKYUKHXTTD67KLANCNFSM4ZJJKKOA.

rnwood avatar Mar 16 '21 20:03 rnwood

I tried to set like this in the docker-compose.yml - ServerOptions__StartTls but still seeing TLS show none when container is started

cdub50 avatar Mar 16 '21 21:03 cdub50

The correct environment setting should be ServerOptions__TlsMode=StartTls


From: cdub50 @.> Sent: Tuesday, March 16, 2021 9:06:45 PM To: rnwood/smtp4dev @.> Cc: Robert Wood @.>; Comment @.> Subject: Re: [rnwood/smtp4dev] TLS Mode (#659)

I tried to set like this in the docker-compose.yml - ServerOptions__StartTls but still seeing TLS show none when container is started

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/rnwood/smtp4dev/issues/659#issuecomment-800604759, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKEGF3SP6RKP4G5KHNOSATTD7B6LANCNFSM4ZJJKKOA.

rnwood avatar Mar 16 '21 21:03 rnwood

thank you!

cdub50 avatar Mar 16 '21 21:03 cdub50

one last thing how do I specify an auto generated self signed cert I tried using

  • ServerOptions__TlsCertificate=""

but I see this error on start

smtp4dev_1 | The SMTP server failed to start: Interop+Crypto+OpenSslCryptographicException: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error smtp4dev_1 | at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromBlob(Byte[] rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) smtp4dev_1 | at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags) smtp4dev_1 | at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags) smtp4dev_1 | at Rnwood.Smtp4dev.Server.Smtp4devServer.GetTlsCertificate() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 106 smtp4dev_1 | at Rnwood.Smtp4dev.Server.Smtp4devServer.CreateSmtpServer() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 67 smtp4dev_1 | at Rnwood.Smtp4dev.Server.Smtp4devServer.TryStart() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 435

cdub50 avatar Mar 16 '21 21:03 cdub50

Comment that out. The default if not specified is to use a self signed cert.


From: cdub50 @.> Sent: Tuesday, March 16, 2021 9:22:26 PM To: rnwood/smtp4dev @.> Cc: Robert Wood @.>; Comment @.> Subject: Re: [rnwood/smtp4dev] TLS Mode (#659)

one last thing how do I specify an auto generated self signed cert I tried using

  • ServerOptions__TlsCertificate=""

but I see this error on start

smtp4dev_1 | The SMTP server failed to start: Interop+Crypto+OpenSslCryptographicException: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error smtp4dev_1 | at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromBlob(Byte[] rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags) smtp4dev_1 | at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags) smtp4dev_1 | at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags) smtp4dev_1 | at Rnwood.Smtp4dev.Server.Smtp4devServer.GetTlsCertificate() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 106 smtp4dev_1 | at Rnwood.Smtp4dev.Server.Smtp4devServer.CreateSmtpServer() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 67 smtp4dev_1 | at Rnwood.Smtp4dev.Server.Smtp4devServer.TryStart() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 435

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/rnwood/smtp4dev/issues/659#issuecomment-800614792, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKEGF5SKZFYA7CR72XFJPTTD7DZFANCNFSM4ZJJKKOA.

rnwood avatar Mar 16 '21 21:03 rnwood

ok thanks again for the help much appreciated!

cdub50 avatar Mar 16 '21 21:03 cdub50

Closing this issue but Docs should be modified to make it more clear on how to add TLS and self signed cert so others dont run into the same issue.

cdub50 avatar Mar 16 '21 22:03 cdub50