jberrenberg / docker-davmail

Docker container for DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway
The Unlicense
39 stars 17 forks source link

davmail ssl #5

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello, I cannot setup ssl following this site: http://davmail.sourceforge.net/sslsetup.html

Unable to bind server socket for SMTP on port 1025: Exception creating secured server socket : davmail.p12 (No such file or directory)Unable to bind server socket for POP on port 1110: Exception creating secured server socket : davmail.p12 (No such file or directory)Unable to bind server socket for IMAP on port 1143: Exception creating secured server socket : davmail.p12 (No such file or directory)Unable to bind server socket for CALDAV on port 1080: Exception creating secured server socket : davmail.p12 (No such file or directory)Unable to bind server socket for LDAP on port 1389: Exception creating secured server socket : davmail.p12 (No such file or directory)

Is everything alright with your container? Thanks

jberrenberg commented 6 years ago

It looks to me as if you are missing the davmail.p12. You might need to mount it into the container via -v /path/of/your/davmail.p12:/path/referenced/in/davmail.properties.

ghost commented 6 years ago

Thanks, but now i'm getting a diferente error:

2018-05-10 11:15:52,316 ERROR [main] davmail - Unable to bind server socket for SMTP on port 1025: Exception creating secured server socket : keystore password was incorrectUnable to bind server socket for POP on port 1110: Exception creating secured server socket : keystore password was incorrectUnable to bind server socket for IMAP on port 1143: Exception creating secured server socket : keystore password was incorrectUnable to bind server socket for CALDAV on port 1080: Exception creating secured server socket : keystore password was incorrectUnable to bind server socket for LDAP on port 1389: Exception creating secured server socket : keystore password was incorrect

My davmail.properties:

# DavMail listeners SSL configuration
davmail.ssl.keystoreType=PKCS12
davmail.ssl.keystoreFile=/etc/davmail/davmail.p12
davmail.ssl.keystorePass=password   
davmail.ssl.keyPass=password

My docker command:

docker run --name davmailhelios --hostname davmailhelios -d --restart=always -p 1025:1025 -p 1080:1080 -p 1143:1143 -p 1389:1389 --restart=always -v /home/root/davmail/davmail.p12:/etc/davmail/davmail.p12 -v /home/root/davmail/davmail.properties:/etc/davmail/davmail.properties jberrenberg/davmail && docker logs davmailhelios -f

jberrenberg commented 6 years ago

Thats odd, the log indicates your keystore password is not password, i just created a fresh keystore using

keytool -genkey -keyalg rsa -keysize 2048 -storepass password -keystore davmail.p12 -storetype pkcs12 -validity 3650 -dname cn=davmailhostname.company.com,ou=davmail,o=sf,o=net

and started the container

docker run -it -v $(pwd)/davmail.properties:/etc/davmail/davmail.properties -v $(pwd)/davmail.p12:/etc/davmail/davmail.p12 -p 1080:1080 jberrenberg/davmail

It worked as expected.

Can you open your keystore using

keytool -list -keystore davmail.p12 -storepass password -storetype PKCS12 -v

or do you get an exception?

ghost commented 6 years ago

No, i get this:

/etc/davmail $ keytool -list -keystore davmail.p12 -storepass password -storetyp e PKCS12 -v

Keystore type: PKCS12 Keystore provider: SunJSSE

Your keystore contains 1 entry

Alias name: mykey Creation date: May 10, 2018 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate[1]: Owner: CN=davmailhostname.company.com, OU=davmail, O=sf, O=net Issuer: CN=davmailhostname.company.com, OU=davmail, O=sf, O=net Serial number: 1b0147da Valid from: Thu May 10 10:41:02 GMT 2018 until: Sun May 07 10:41:02 GMT 2028 Certificate fingerprints: MD5: B7:43:EE:D9:EF:06:CA:53:25:22:C3:33:52:48:A0:88 SHA1: 01:9F:8C:8F:39:B1:56:00:3E:0B:B5:59:E1:0B:95:08:3A:AE:D6:69 SHA256: 0F:12:0A:94:26:3E:6F:EA:28:15:B1:25:44:2F:46:E6:2A:E7:0C:4E:79:FA:2C:EF:80:6D:1B:18:DC:EB:80:C1 Signature algorithm name: SHA256withRSA Subject Public Key Algorithm: 2048-bit RSA key Version: 3

Extensions:

1: ObjectId: 2.5.29.14 Criticality=false

SubjectKeyIdentifier [ KeyIdentifier [ 0000: 2D E1 D9 CB CF EE 19 44 7B 47 CC C2 6D FD A3 7E -......D.G..m... 0010: 5D 18 C7 6E ]..n ] ]



ghost commented 6 years ago

I got it to work but now :) when configuring thunderbird and i'm getting this errors:

Exception in thread "ImapConnection-36720" java.lang.NoClassDefFoundError: Could not initialize class sun.security.ssl.SupportedEllipticCurvesExtension at sun.security.ssl.HelloExtensions.(HelloExtensions.java:85) at sun.security.ssl.HandshakeMessage$ClientHello.(HandshakeMessage.java:240) at sun.security.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:219) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:961) at sun.security.ssl.Handshaker.process_record(Handshaker.java:897) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1033) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1342) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:719) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at davmail.AbstractConnection.sendClient(AbstractConnection.java:188) at davmail.AbstractConnection.sendClient(AbstractConnection.java:168) at davmail.imap.ImapConnection.run(ImapConnection.java:82) Exception in thread "SmtpConnection-47774" java.lang.NoClassDefFoundError: Could not initialize class sun.security.ssl.SupportedEllipticCurvesExtension at sun.security.ssl.HelloExtensions.(HelloExtensions.java:85) at sun.security.ssl.HandshakeMessage$ClientHello.(HandshakeMessage.java:240) at sun.security.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:219) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:961) at sun.security.ssl.Handshaker.process_record(Handshaker.java:897) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1033) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1342) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:719) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at davmail.AbstractConnection.sendClient(AbstractConnection.java:188) at davmail.AbstractConnection.sendClient(AbstractConnection.java:168) at davmail.smtp.SmtpConnection.run(SmtpConnection.java:66) 2018-05-11 11:10:35,261 ERROR [ImapConnection-58280] davmail - Remote host closed connection during handshake javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:963) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1342) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:719) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at davmail.AbstractConnection.sendClient(AbstractConnection.java:188) at davmail.AbstractConnection.sendClient(AbstractConnection.java:168) at davmail.imap.ImapConnection.run(ImapConnection.java:82) Caused by: java.io.EOFException: SSL peer shut down incorrectly at sun.security.ssl.InputRecord.read(InputRecord.java:482) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:944) ... 8 more 2018-05-11 11:10:35,262 WARN [ImapConnection-58280] davmail - Exception sending error to client Connection has been shutdown: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1506) at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1518) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:70) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at davmail.AbstractConnection.sendClient(AbstractConnection.java:188) at davmail.AbstractConnection.sendClient(AbstractConnection.java:168) at davmail.imap.ImapConnection.run(ImapConnection.java:670) Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:963) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1342) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:719) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at davmail.AbstractConnection.sendClient(AbstractConnection.java:188) at davmail.AbstractConnection.sendClient(AbstractConnection.java:168) at davmail.imap.ImapConnection.run(ImapConnection.java:82) Caused by: java.io.EOFException: SSL peer shut down incorrectly at sun.security.ssl.InputRecord.read(InputRecord.java:482) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:944) ... 8 more

My thunderbird conf:

screenshot from 2018-05-11 12-13-45