I am trying to setup security for Mongodb using SSL certificates and I am trying to concatenate the key and crt files using CAT command.

Where would I concatenate? OpenSSL or mongod ?

cat mongodb-cert.key mongodb-cert.crt > mongodb.pem

  • Location of the file is not that important. Put it somewhere under /etc. Then you use full qualified path at /etc/mongod.conf file to point it. – JJussi Apr 17 '18 at 3:54
  • @SQLUser, Welcome to the site. How you have put up the certificate file and you have mention in "mongod.conf" of that file is qualified path or not. – Md Haidar Ali Khan Apr 17 '18 at 10:14
  • @SQLUser, What is O.S Environment? – Md Haidar Ali Khan Apr 19 '18 at 13:51

As MongoDB Blog Documentation here To Create .pem file from private certificate authority you have to connect through OpenSSL.

cat mongodb.key mongodb.crt > mongodb.pem

To Enabling TLS on a self-hosted or self-managed MongoDB server

Open /etc/mongod.conf with your favorite code editor and make sure it contains the following lines:

    mode: requireSSL
    PEMKeyFile: <route-to-cert-file>
    CAFile: <route-to-ca-file>

If you can’t find mongod.conf or it is named mongodb.conf instead, it means that you are using a really old and broken version of MongoDB. Please read this guide on how to upgrade to a more recent version.)

Please replace <route-to-cert-file> with the route of the .pem file that contains the signed SSL certificate and key., e.g.: /etc/ssl/mongodb.pem .

Also replace <route-to-ca-file> with the route of the .pem file that contains the root certificate chain from the Certificate Authority, e.g.: /etc/ssl/ca.pem

For your further ref here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.