{"id":130,"date":"2021-07-01T14:19:11","date_gmt":"2021-07-01T11:19:11","guid":{"rendered":"http:\/\/www.gmerden.com\/?p=130"},"modified":"2026-01-31T21:15:02","modified_gmt":"2026-01-31T21:15:02","slug":"convert-pfx-to-crt-key-file-and-use-it-on-nginx","status":"publish","type":"post","link":"https:\/\/www.gmerden.com\/index.php\/2021\/07\/01\/convert-pfx-to-crt-key-file-and-use-it-on-nginx\/","title":{"rendered":"Convert Pfx to .crt\/.key file and use it on nginx"},"content":{"rendered":"\n<p>   A pfx file has been sent to active ssl on nginx. So what can i do to active certificate on nginx. Let&#8217;s look closer what steps will be done?<\/p>\n\n\n\n<p>   First of all, we have to create encrypted key file and crt file. Follwing code block shows us how encrypted key file can be created. <\/p>\n\n\n\n<p><code>openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]<\/code><\/p>\n\n\n\n<p>   Second, we are creating crt file via following code.<\/p>\n\n\n\n<p><code>openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]<\/code><\/p>\n\n\n\n<p>   Third step is creating ca certificate via following code<\/p>\n\n\n\n<p><code>openssl pkcs12 -in certfile.pfx -cacerts -out bundle.crt<\/code><\/p>\n\n\n\n<p>   Now we have created cl and ca crt file so we can use it on nginx. We will concat those files.<\/p>\n\n\n\n<p><code>cat [certificate.crt] [bundle.crt] &gt; [domain.tld.chained.crt<\/code>]<\/p>\n\n\n\n<p>One more step is be done. We have created encyrpted key file before. Afterwards we will decrypt it via following code.<\/p>\n\n\n\n<p><code>openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key]<\/code><\/p>\n\n\n\n<p>Finally, we will use key and crt files in nginx configuration.<\/p>\n\n\n\n<p>server {<br>listen 80;<br>listen 443 ssl;<br>server_name [your-domain-name];<br>ssl_certificate   <code>[domain.tld.chained.crt<\/code>];<br>ssl_certificate_key   [keyfile-decrypted.key];<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>All we have to do ise restart nginx and start using new certificate. Thanks for reading. If you have any questions, please don&#8217;t hesitate to ask.<\/p>\n\n\n\n<p>Source: <a href=\"https:\/\/xy2z.io\/posts\/2020-pfx-certificates-nginx-apache2\/\" data-type=\"URL\" data-id=\"https:\/\/xy2z.io\/posts\/2020-pfx-certificates-nginx-apache2\/\">https:\/\/xy2z.io\/posts\/2020-pfx-certificates-nginx-apache2\/<\/a><\/p>\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>A pfx file has been sent to active ssl on nginx. So what can i do to active certificate on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[3],"tags":[],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-software-development"],"_links":{"self":[{"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":4,"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":450,"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/posts\/130\/revisions\/450"}],"wp:attachment":[{"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gmerden.com\/index.php\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}