[GH-ISSUE #387] Docker compose TLS/SSL ceriftcate not readebale #250

Closed
opened 2026-03-15 13:27:05 +03:00 by kerem · 10 comments
Owner

Originally created by @aiamk on GitHub (Nov 14, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/387

hello,

i tried all the ways and still didn't figure out how to solve this permission issue in docker, Kindly I need your help, i am not sure if i did a mistake or i missed something:

2024-11-14 21:18:39 time="2024/11/14 18:18:39" level=error msg="[smtp] TLS key not found or readable: =/certs/localhostKey.pem"


    mailpit:
        image: axllent/mailpit
        volumes:
            - './docker/mailpit/data:/data'
            - './docker/certs:/certs'
        ports:
            - 8025:8025
            - 1025:1025
        environment:
            MP_MAX_MESSAGES: 5000
            MP_DATABASE: /data/mailpit.db
            MP_SMTP_AUTH_ACCEPT_ANY: true
            MP_SMTP_AUTH_ALLOW_INSECURE: true
            
            MP_SMTP_TLS_KEY=: '/certs/localhostKey.pem'
            MP_SMTP_TLS_CERT: '/certs/localhostCert.pem'

            MP_SMTP_REQUIRE_STARTTLS: true
            MP_SMTP_REQUIRE_TLS: true
            MP_SMTP_AUTH: "webmaster:password info:password"

Best Regards.

Originally created by @aiamk on GitHub (Nov 14, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/387 hello, i tried all the ways and still didn't figure out how to solve this permission issue in docker, Kindly I need your help, i am not sure if i did a mistake or i missed something: `2024-11-14 21:18:39 time="2024/11/14 18:18:39" level=error msg="[smtp] TLS key not found or readable: =/certs/localhostKey.pem"` ``` mailpit: image: axllent/mailpit volumes: - './docker/mailpit/data:/data' - './docker/certs:/certs' ports: - 8025:8025 - 1025:1025 environment: MP_MAX_MESSAGES: 5000 MP_DATABASE: /data/mailpit.db MP_SMTP_AUTH_ACCEPT_ANY: true MP_SMTP_AUTH_ALLOW_INSECURE: true MP_SMTP_TLS_KEY=: '/certs/localhostKey.pem' MP_SMTP_TLS_CERT: '/certs/localhostCert.pem' MP_SMTP_REQUIRE_STARTTLS: true MP_SMTP_REQUIRE_TLS: true MP_SMTP_AUTH: "webmaster:password info:password" ``` Best Regards.
kerem closed this issue 2026-03-15 13:27:11 +03:00
Author
Owner

@axllent commented on GitHub (Nov 14, 2024):

Hi @aiamk. Do those certificates exist?

<!-- gh-comment-id:2477180397 --> @axllent commented on GitHub (Nov 14, 2024): Hi @aiamk. Do those certificates exist?
Author
Owner

@aiamk commented on GitHub (Nov 14, 2024):

yes, i already checked them in mailpit container, i even made another certificates and i had the same issue

<!-- gh-comment-id:2477196747 --> @aiamk commented on GitHub (Nov 14, 2024): yes, i already checked them in mailpit container, i even made another certificates and i had the same issue
Author
Owner

@axllent commented on GitHub (Nov 14, 2024):

Considering they are self-signed certificates, could you please attach them here so I can try & investigate? Thanks.

<!-- gh-comment-id:2477234186 --> @axllent commented on GitHub (Nov 14, 2024): Considering they are self-signed certificates, could you please attach them here so I can try & investigate? Thanks.
Author
Owner

@aiamk commented on GitHub (Nov 14, 2024):

sure :

-----BEGIN CERTIFICATE-----
MIIEHzCCAoegAwIBAgIRAMLNiR2uS+sh5OZquhD7k34wDQYJKoZIhvcNAQELBQAw
WzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMRgwFgYDVQQLDA9haWFt
a0BhaWFtay1wcGMxHzAdBgNVBAMMFm1rY2VydCBhaWFta0BhaWFtay1wcGMwHhcN
MjQxMDAxMTI1MzE3WhcNMjcwMTAxMTI1MzE3WjBDMScwJQYDVQQKEx5ta2NlcnQg
ZGV2ZWxvcG1lbnQgY2VydGlmaWNhdGUxGDAWBgNVBAsMD2FpYW1rQGFpYW1rLXBw
YzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANomnP6Udo0OjpwxYbQZ
FIFazSxjzss6xwPozbhDDoQHUm9QPAd8k0C6/Ntn9392ggI4b6v/78CKTYjKr/Bx
uUpODz185gdbMX8CVlp7BLFxMqnHDdT6snfshiCn7GJE8rePVhHmCm3D85o22TkV
OqPKj9GrCMfEZZVVRfu/pKlNf5BtYrvdXDyLpRN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O2DjJB
O6gTAOqYuzLAKgwy6G2M3D4gOPK/9u7uVxmtL5Wkf08HUE3M6cQtmOxvmtkCgYEA
ygD+R3mvj97x4+ZNLvrIpihKd0FlOxc2GEmtcYkl9cqAjeAaRI4knPKiDoe/TJp0
YcUH8/A1hTJkLQ9jLZWtwBcaVIVdijn7sSdWwdOzrGtVwOMe9l9RIwD6Bw1qBDmc
PBs1j9Z/n5tPdnIseSnQdsdEOXz/r54BseUKk6had9ECgYEAllTMCawM9/3bpYN8
wX3qahUZtAoadSEc/gdv3FHAHTDoOPLX+paNd0MdIxSc/5o6hS5NLMHuMMtYpDMf
6rT1VWKXBhnhIsIGm/TJ8anYHiCsZE1+4nEkLkZEFgnQbLy8/8tgAvYhKufG+iES
A1fYpz4B3xHTDrwbzU+QYMHhKMc=
-----END PRIVATE KEY-----
<!-- gh-comment-id:2477252814 --> @aiamk commented on GitHub (Nov 14, 2024): sure : ``` -----BEGIN CERTIFICATE----- MIIEHzCCAoegAwIBAgIRAMLNiR2uS+sh5OZquhD7k34wDQYJKoZIhvcNAQELBQAw WzEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMRgwFgYDVQQLDA9haWFt a0BhaWFtay1wcGMxHzAdBgNVBAMMFm1rY2VydCBhaWFta0BhaWFtay1wcGMwHhcN MjQxMDAxMTI1MzE3WhcNMjcwMTAxMTI1MzE3WjBDMScwJQYDVQQKEx5ta2NlcnQg ZGV2ZWxvcG1lbnQgY2VydGlmaWNhdGUxGDAWBgNVBAsMD2FpYW1rQGFpYW1rLXBw YzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANomnP6Udo0OjpwxYbQZ FIFazSxjzss6xwPozbhDDoQHUm9QPAd8k0C6/Ntn9392ggI4b6v/78CKTYjKr/Bx uUpODz185gdbMX8CVlp7BLFxMqnHDdT6snfshiCn7GJE8rePVhHmCm3D85o22TkV OqPKj9GrCMfEZZVVRfu/pKlNf5BtYrvdXDyLpRNOnUnt1bVQ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gOPK/9u7uVxmtL5Wkf08HUE3M6cQtmOxvmtkCgYEA ygD+R3mvj97x4+ZNLvrIpihKd0FlOxc2GEmtcYkl9cqAjeAaRI4knPKiDoe/TJp0 YcUH8/A1hTJkLQ9jLZWtwBcaVIVdijn7sSdWwdOzrGtVwOMe9l9RIwD6Bw1qBDmc PBs1j9Z/n5tPdnIseSnQdsdEOXz/r54BseUKk6had9ECgYEAllTMCawM9/3bpYN8 wX3qahUZtAoadSEc/gdv3FHAHTDoOPLX+paNd0MdIxSc/5o6hS5NLMHuMMtYpDMf 6rT1VWKXBhnhIsIGm/TJ8anYHiCsZE1+4nEkLkZEFgnQbLy8/8tgAvYhKufG+iES A1fYpz4B3xHTDrwbzU+QYMHhKMc= -----END PRIVATE KEY----- ```
Author
Owner

@axllent commented on GitHub (Nov 14, 2024):

Thanks. I'll need to get back to you in about 6 hours 👍

<!-- gh-comment-id:2477348012 --> @axllent commented on GitHub (Nov 14, 2024): Thanks. I'll need to get back to you in about 6 hours :+1:
Author
Owner

@aiamk commented on GitHub (Nov 14, 2024):

take your time bro,
i appreciate your help,
thank you

<!-- gh-comment-id:2477426705 --> @aiamk commented on GitHub (Nov 14, 2024): take your time bro, i appreciate your help, thank you
Author
Owner

@axllent commented on GitHub (Nov 15, 2024):

OK, so your options are all over the place (you have several conflicting requirements), and more importantly, you have a typo in your YAML syntax which is the cause of your reported error - MP_SMTP_TLS_KEY=: '/certs/localhostKey.pem' has a =: which is invalid and is probably causing an extra pace or something in the path. It should be MP_SMTP_TLS_KEY: '/certs/localhostKey.pem' which works fine here.

So, (after fixing the typo) and depending on what you are trying to achieve here:

  1. You can set MP_SMTP_REQUIRE_STARTTLS or MP_SMTP_REQUIRE_TLS (or neither), but not both
  2. You can set MP_SMTP_AUTH_ACCEPT_ANY or MP_SMTP_AUTH (or neither), but not both

Without knowing what environment you are trying to replicate I cannot give you more direction. Using a self-signed certificate is perfectly fine, provided you have control over the SMTP client to accept a self-signed certificate. Most of the time I don't use any TLS for SMTP as I don't need to test that and it makes my life much easier.

Based on what you pasted, I think your configuration should be:

services:
  mailpit:
    image: axllent/mailpit
    volumes:
      - './docker/mailpit/data:/data'
      - './docker/certs:/certs'
    ports:
      - 8025:8025
      - 1025:1025
    environment:
      MP_MAX_MESSAGES: 5000
      MP_DATABASE: /data/mailpit.db
      
      MP_SMTP_TLS_KEY: '/certs/localhostKey.pem'
      MP_SMTP_TLS_CERT: '/certs/localhostCert.pem'

      MP_SMTP_REQUIRE_STARTTLS: true
      MP_SMTP_AUTH: "webmaster:password info:password"

This will provide you with a STARTTLS requirement (for a self-signed certificate) and SMTP authentication requiring either webmaster:password or info:password as credentials.

I hope this helps!

<!-- gh-comment-id:2477812918 --> @axllent commented on GitHub (Nov 15, 2024): OK, so your options are all over the place (you have several conflicting requirements), and more importantly, you have a typo in your YAML syntax which is the cause of your reported error - `MP_SMTP_TLS_KEY=: '/certs/localhostKey.pem'` has a `=:` which is invalid and is probably causing an extra pace or something in the path. It should be ` MP_SMTP_TLS_KEY: '/certs/localhostKey.pem'` which works fine here. So, (after fixing the typo) and depending on what you are trying to achieve here: 1. You can set `MP_SMTP_REQUIRE_STARTTLS` or `MP_SMTP_REQUIRE_TLS` (or neither), but not both 2. You can set `MP_SMTP_AUTH_ACCEPT_ANY` or `MP_SMTP_AUTH` (or neither), but not both Without knowing what environment you are trying to replicate I cannot give you more direction. Using a self-signed certificate is perfectly fine, provided you have control over the SMTP client to accept a self-signed certificate. Most of the time I don't use any TLS for SMTP as I don't need to test that and it makes my life much easier. Based on what you pasted, I think your configuration should be: ```yaml services: mailpit: image: axllent/mailpit volumes: - './docker/mailpit/data:/data' - './docker/certs:/certs' ports: - 8025:8025 - 1025:1025 environment: MP_MAX_MESSAGES: 5000 MP_DATABASE: /data/mailpit.db MP_SMTP_TLS_KEY: '/certs/localhostKey.pem' MP_SMTP_TLS_CERT: '/certs/localhostCert.pem' MP_SMTP_REQUIRE_STARTTLS: true MP_SMTP_AUTH: "webmaster:password info:password" ``` This will provide you with a STARTTLS requirement (for a self-signed certificate) and SMTP authentication requiring either `webmaster:password` or `info:password` as credentials. I hope this helps!
Author
Owner

@aiamk commented on GitHub (Nov 15, 2024):

thank you very much bro for you efforts & help,
i am very sorry of this inconvenience typo mistake in docker compose, i couldn't see means i am getting old :|

actually i need tls & ssl to test my email library.

Best Regards,

<!-- gh-comment-id:2479470853 --> @aiamk commented on GitHub (Nov 15, 2024): thank you very much bro for you efforts & help, i am very sorry of this inconvenience typo mistake in docker compose, i couldn't see means i am getting old :| actually i need tls & ssl to test my email library. Best Regards,
Author
Owner

@axllent commented on GitHub (Nov 15, 2024):

It's no problem, we all make mistakes!

<!-- gh-comment-id:2479625082 --> @axllent commented on GitHub (Nov 15, 2024): It's no problem, we all make mistakes!
Author
Owner

@axllent commented on GitHub (Nov 16, 2024):

And thank you for the donation! ❤️

<!-- gh-comment-id:2480288331 --> @axllent commented on GitHub (Nov 16, 2024): And thank you for the donation! :heart:
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#250
No description provided.