{"id":92,"date":"2023-02-15T19:43:43","date_gmt":"2023-02-15T19:43:43","guid":{"rendered":"https:\/\/hostpika.com\/blog\/?p=92"},"modified":"2023-02-15T19:43:45","modified_gmt":"2023-02-15T19:43:45","slug":"how-to-create-ssl-certificate-on-ubuntu22-04-lts-x64-droplet-for-mongo","status":"publish","type":"post","link":"https:\/\/hostpika.com\/blog\/how-to-create-ssl-certificate-on-ubuntu22-04-lts-x64-droplet-for-mongo\/","title":{"rendered":"How to create SSL certificate on Ubuntu(22.04 (LTS) x64) droplet for Mongo?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">To create an SSL certificate on Ubuntu 22.04 (LTS) x64 for MongoDB, you can follow these steps:<\/h2>\n\n\n\n<p>1. Install OpenSSL: If you don&#8217;t have OpenSSL installed on your system, you can install it by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install openssl\r\n<\/code><\/pre>\n\n\n\n<p>2. Generate a private key: Use OpenSSL to generate a new private key by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo openssl genrsa -out mongodb.key 2048\r\n<\/code><\/pre>\n\n\n\n<p>3. Generate a certificate signing request: Use OpenSSL to generate a certificate signing request (CSR) by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo openssl req -new -key mongodb.key -out mongodb.csr\r\n<\/code><\/pre>\n\n\n\n<p>You will be prompted to enter information about your organization, such as your country, state\/province, and company name.<\/p>\n\n\n\n<p>4. Get your CSR signed: Send your CSR to a Certificate Authority (CA) to get it signed. There are many CAs that offer SSL certificates, such as Let&#8217;s Encrypt or Digicert. Follow the instructions provided by the CA to complete this step.<\/p>\n\n\n\n<p>5. Combine the key and certificate: Once you receive the signed certificate from the CA, you can combine it with the private key to create a single file that contains both. Run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo cat mongodb.crt mongodb.key >> mongodb.pem\r\n<\/code><\/pre>\n\n\n\n<p>Where &#8220;mongodb.crt&#8221; is the signed certificate file you received from the CA.<\/p>\n\n\n\n<p>6. Configure MongoDB to use the SSL certificate: You can now configure MongoDB to use the SSL certificate by updating your MongoDB configuration file. Set the &#8220;sslMode&#8221; option to &#8220;requireSSL&#8221; and the &#8220;sslPEMKeyFile&#8221; option to the path of the &#8220;mongodb.pem&#8221; file you created earlier. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>net:\r\n  port: 27017\r\n  ssl:\r\n    mode: requireSSL\r\n    PEMKeyFile: \/path\/to\/mongodb.pem\r\n<\/code><\/pre>\n\n\n\n<p>7. Restart MongoDB: Finally, restart MongoDB to apply the changes to the configuration file. You can do this by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl restart mongodb\r\n<\/pre>\n\n\n\n<p>That&#8217;s it! Your MongoDB server is now configured to use SSL with the certificate you created.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To create an SSL certificate on Ubuntu 22.04 (LTS) x64 for MongoDB, you can follow these steps: 1. &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to create SSL certificate on Ubuntu(22.04 (LTS) x64) droplet for Mongo?\" class=\"read-more button\" href=\"https:\/\/hostpika.com\/blog\/how-to-create-ssl-certificate-on-ubuntu22-04-lts-x64-droplet-for-mongo\/#more-92\" aria-label=\"More on How to create SSL certificate on Ubuntu(22.04 (LTS) x64) droplet for Mongo?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":93,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,19],"tags":[17,18],"class_list":["post-92","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial","category-ubuntu","tag-droplet-for-mongo","tag-ssl-certificate","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/posts\/92","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/comments?post=92"}],"version-history":[{"count":1,"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/posts\/92\/revisions\/94"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/media\/93"}],"wp:attachment":[{"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/media?parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/categories?post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostpika.com\/blog\/wp-json\/wp\/v2\/tags?post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}