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

    How to add an imported ca's private key afterwards (edit: ca 2x in the config?)

    Scheduled Pinned Locked Moved 2.0-RC Snapshot Feedback and Problems - RETIRED
    12 Posts 2 Posters 3.5k Views
    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.
    • M Offline
      mxx
      last edited by

      Hi,

      When I started to use pfsense in May, it was only possible to import a foreign ca's certificate, not its private key.
      Since some time you added the option to also import the private key of a ca.

      Is it somehow possible to add the private key to a previously imported ca crt?
      I was thinking of deleting this ca and reimporting it with its private key, but then the caref wouldn't be the same I guess and this would break my ipsec configuration which uses a certificate signed by that ca. Or am I wrong?

      When I look inside the config the certificates and private keys are encoded differently so I couldn't manually add it by copying and pasting.

      Thank you very much for any help!

      Max

      1 Reply Last reply Reply Quote 0
      • jimpJ Offline
        jimp Rebel Alliance Developer Netgate
        last edited by

        I don't think I have a way to do that in the GUI. Didn't think it would be needed really.

        You are right the caref would be different in that case. I may have to revisit the issue.

        The 'encoding' is just a base64_encode() of the text in the input field.

        So if you can go to Diagnostics > Command and do something like:

        $foo = <<<eod<br>blahblahcertdatablah
        EOD;
        echo base64_encode($foo);</eod<br>
        

        And then hack the result into the config in the proper place, that would work for now.

        Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • M Offline
          mxx
          last edited by

          Wow, thanks jimp for the fast answer!

          I will try that!

          Thanks!

          1 Reply Last reply Reply Quote 0
          • M Offline
            mxx
            last edited by

            Hmm sorry I got another question about the config:

            Why do the ca certificate and private key data exist 2 times in the config?
            Also what about the serial tag regarding the ca?

            The internal ca certificate data have a serial of 25 at the first place in the config and a serial of 26 at the second (at the bottom of the file).

            When I was to add that private key to the external ca, would I also need to add it 2 times and add a serial tag (which doesn't exist yet for this imported ca)?

            Thank you!

            1 Reply Last reply Reply Quote 0
            • jimpJ Offline
              jimp Rebel Alliance Developer Netgate
              last edited by

              It shouldn't exist twice in the config.

              If you see it under <system>, that should have been removed when I relocated the certificate code out from under there. Those entries are no longer used and can be deleted.</system>

              Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

              1 Reply Last reply Reply Quote 0
              • M Offline
                mxx
                last edited by

                ok thanks, but what about the serial tag? Why is there a serial for the internal ca and none for the imported one?

                1 Reply Last reply Reply Quote 0
                • M Offline
                  mxx
                  last edited by

                  Can I delete any <cert>tags under system or just the ca ones?</cert>

                  1 Reply Last reply Reply Quote 0
                  • jimpJ Offline
                    jimp Rebel Alliance Developer Netgate
                    last edited by

                    I'd have to trace back through the code again to remember that one. I think it was something of a revision tag, but you can probably add one safely as "1". It isn't a unique ID, that's the refid, so the serial isn't used for significant things like that.

                    You can delete any <ca>, <cert>, or <crl>tags under <system>.</system></crl></cert></ca>

                    Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                    Need help fast? Netgate Global Support!

                    Do not Chat/PM for help!

                    1 Reply Last reply Reply Quote 0
                    • jimpJ Offline
                      jimp Rebel Alliance Developer Netgate
                      last edited by

                      This was stuck in my inbox, haunting me, but I finally managed to work up a fix.

                      https://rcs.pfsense.org/projects/pfsense/repos/mainline/commits/bfa992bc4eb8f8674f44b94e8617a032854356e9

                      You should be able to edit CAs and add private keys now.

                      Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                      Need help fast? Netgate Global Support!

                      Do not Chat/PM for help!

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        mxx
                        last edited by

                        Thank you jimp!
                        This is great! At least for me it's very useful since I have some imported CA's left from the time where you couldn't import priv.keys.
                        Also if you changed your mind and wanted to add the priv key later.. it's a great feature.

                        Thank you!

                        1 Reply Last reply Reply Quote 0
                        • jimpJ Offline
                          jimp Rebel Alliance Developer Netgate
                          last edited by

                          Just remember when importing a CA to check what your highest certificate serial number is and set it in the GUI as appropriate, so you don't get certificates with overlapping serials. (It makes revoking them a PITA)

                          Remember: Upvote with the ๐Ÿ‘ button for any user/post you find to be helpful, informative, or deserving of recognition!

                          Need help fast? Netgate Global Support!

                          Do not Chat/PM for help!

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            mxx
                            last edited by

                            Thnx I'll watch out and try it out once I can upgrade the box.

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