• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

[SOLVED] SMTP notification error (SMTP: Failed to connect socket: fsockopen()...) with TLS and private CA

General pfSense Questions
smtp intermediate ca tls
4
12
9.5k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G
    Gertjan @Sandokan
    last edited by Dec 3, 2018, 7:06 AM

    @sandokan said in SMTP notification error (SMTP: Failed to connect socket: fsockopen()...) with TLS and intermediate CA:

    The notification setup uses port 465 and explicit SSL/TLS (Enable SMTP over SSL/TLS) checked - as per server configuration.

    When you use a classic mail client like Outlook or Thunderbird, SMTP over TLS using 465 works for sending out mail ?
    Did you saw the "Do not trust the CA ?" message, even ones ?

    I guess you are using a self-signed certificate. In that case, importing your won CA should do the job.

    Btw : because obtaining a cert from globally recognized CA is more easy as making up your own, all my mail servers are using these "trusted by all" CA's (fro example : LetEnscrypt : set it and forget it).

    Anther test : if you have a gmail accoiunt, relay notification mail over to them. This should work, using the mandatory SMTP:465 + TLS.

    No "help me" PM's please. Use the forum, the community will thank you.
    Edit : and where are the logs ??

    1 Reply Last reply Reply Quote 0
    • S
      Sandokan
      last edited by Dec 3, 2018, 11:17 AM

      Thank you for your reply. The mail server is an internal one - that's why it does have an internal PKI certificate. I can send and receive email using any mail client, and other devices using internal SMTP notifications as well.

      The certificate isn't self signed, the internal PKI structure is as follow:

      "Internal CA" -> "Internal intermediate CA" -> "mail server certificate"

      There are different intermediate CAs depending on the type of certificate issues (the CA issuing server certificates doesn't issue users or code signing certificates, for example). I was planning to add another intermediate CA to issue VPN certificates.

      My first attempts were made after I imported the "internal CA" into pfSense (and a server certificate for pfSense itself, no issues)

      Then I tried again after importing the "internal intermediate CA" as well. pfSense does recognize that the "internal intermediate CA" is issued by "internal CA". But SMTP certificate check still fails.

      I'm starting to wonder what CAs list the SMTP process is using, and if CAs imported into pfSense are available to all processes or not (i.e. stored in FreeBSD CAs store) - and how the SMTP process performs the certificate chain check.

      I didn't try with an external service yet, I believe it would work, but it's not an option in this case.

      1 Reply Last reply Reply Quote 0
      • G
        Grimson Banned
        last edited by Dec 3, 2018, 11:30 AM

        https://forum.netgate.com/topic/125582/solved-need-to-add-an-upstream-certificate-for-my-fw

        1 Reply Last reply Reply Quote 1
        • S
          Sandokan
          last edited by Dec 3, 2018, 12:55 PM

          Thank you for the link, it confirmed my suspicions.

          I was looking into the OS CA lists and I didn't find the CA I uploaded into pfSense. So it looks they are stored elsewhere, and aren't used for verification by some of the processes/services - which IMHO looks like a bug to me, or at least lack of proper documentation, if the CA imported into pfSense are used only for some tasks and not others.

          Adding them to the OS lists is not a problem, it needs to be done just once until the expiration date - I just hope an update won't reset the lists.

          1 Reply Last reply Reply Quote 0
          • G
            Gertjan
            last edited by Dec 3, 2018, 2:12 PM

            Test also with :

            openssl s_client -CAfile /chemin/vers/ton/ca-certificates.crt-connect mail.ton-server.tld:465
            

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            1 Reply Last reply Reply Quote 0
            • S
              Sandokan
              last edited by Sandokan Dec 3, 2018, 7:11 PM Dec 3, 2018, 7:10 PM

              Solved.

              After adding my CA to /usr/local/share/certs/ca-root-nss.crt the mail message was properly sent. I dumped the certificate contents using:

              openssl x509 -in ca_certificate.pem -text
              

              And added the output to the end of the file.

              Evidently that is the CAs list used by the SMTP sending code.

              Thank you everybody for pointing me in the right direction.

              1 Reply Last reply Reply Quote 1
              • S
                Sandokan
                last edited by Dec 3, 2018, 10:41 PM

                I didn't see it before, or 2.4.4-p1 added an option to disable certificate validation?

                1 Reply Last reply Reply Quote 0
                • G
                  Gertjan
                  last edited by Dec 3, 2018, 11:02 PM

                  This one

                  🔒 Log in to view

                  ?

                  No "help me" PM's please. Use the forum, the community will thank you.
                  Edit : and where are the logs ??

                  S 1 Reply Last reply Dec 4, 2018, 10:09 AM Reply Quote 0
                  • S
                    Sandokan @Gertjan
                    last edited by Dec 4, 2018, 10:09 AM

                    @gertjan

                    Yes. Was it added in the latest release, or I was so blind I didn't see it before?

                    1 Reply Last reply Reply Quote 0
                    • G
                      Gertjan
                      last edited by Dec 4, 2018, 10:19 AM

                      It's new : https://github.com/pfsense/pfsense/commits/master/src/usr/local/www/system_advanced_notifications.php

                      No "help me" PM's please. Use the forum, the community will thank you.
                      Edit : and where are the logs ??

                      1 Reply Last reply Reply Quote 0
                      • A
                        adamf663
                        last edited by Aug 26, 2019, 10:13 PM

                        Not fixed as of 2.4.4-RELEASE-p3 (amd64)
                        built on Wed May 15 18:53:44 EDT 2019
                        FreeBSD 11.2-RELEASE-p10.

                        Only after appending the text dump of my ca cert to /usr/local/share/certs/ca-root-nss.crt was I able to send test messages.
                        "Validate the SSL/TLS certificate presented by the server" had no effect.
                        Package captures verified that pfsense was rejecting the certificate being returned by my email server.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.