{"id":59,"date":"2020-09-25T16:45:18","date_gmt":"2020-09-25T14:45:18","guid":{"rendered":"http:\/\/inorr.net\/?p=59"},"modified":"2023-01-02T13:14:13","modified_gmt":"2023-01-02T12:14:13","slug":"arbeta-med-cert-och-nyckel-i-openssl","status":"publish","type":"post","link":"https:\/\/inorr.net\/?p=59","title":{"rendered":"Arbeta med cert och nyckel i OpenSSL"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Extract .crt and .key files from .pfx file<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Start OpenSSL from the OpenSSL\\bin folder.<br>Open the command prompt and go to the folder that contains your .pfx file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command to extract the private key:<br><strong>openssl pkcs12 -in [yourfile.pfx] -nocerts -out [drlive.key]<\/strong><br>You will be prompted to type the import password. Type the password that you used to protect your keypair when you created the .pfx file. <br>You will be prompted again to provide a new password to protect the .key file that you are creating. Store the password to your key file in a secure place to avoid misuse.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command to extract the certificate:<br><strong>openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [drlive.crt]<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command to decrypt the private key:<br><strong>openssl rsa -in [drlive.key] -out [drlive-decrypted.key]<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Type the password that you created to protect the private key file in the previous step.<br>The .crt file and the decrypted and encrypted .key files are available in the path, where you started OpenSSL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Merge certificate and private key<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">OpenSSL.exe pkcs12 \u2013export \u2013in certfile.cer \u2013inkey certfile.key \u2013out certfile.pfx<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ange det tillf\u00e4lliga l\u00f6senord du vill anv\u00e4nda f\u00f6r att skydda PFX-filen<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Importera PFX-filen lokalt p\u00e5 den dator d\u00e4r den genererades, v\u00e4lj att private key ska kunna exporteras och exportera sedan p\u00e5 nytt med det l\u00f6senord du vill ska skydda och att private key ska ing\u00e5. <br>G\u00f6r man inte detta kan det vara sv\u00e5rt importera PFX-filen p\u00e5 en annan dator.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Extract Private Key from PFX<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following command will extract the private key from the .pfx file. A new file private-key.pem will be created in current directory. <br>This command required a password set on the pfx file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">openssl pkcs12 -in myfile.pfx -nocerts -out private-key.pem -nodes<br>Enter Import Password:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the result file (private-key.pem) and copy text between and encluding \u2014\u2013BEGIN PRIVATE KEY\u2014\u2013 and \u2014\u2013END CERTIFICATE\u2014\u2013 text.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Extract Certificate from PFX<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Then extract the certificate file. The following command will extract the certificate from the .pfx file. <br>You can find the certificate in file named certificate.pem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">openssl pkcs12 -in myfile.pfx -nokeys -out certificate.pem<br>Enter Import Password:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the result file (certificate.pem) and copy text between and encluding \u2014\u2013BEGIN CERTIFICATE\u2014\u2013 and \u2014\u2013END CERTIFICATE\u2014\u2013 text.<br>This file may also include the other certificate chain. The first block will be your domain certificate and others will be the chain.<br>You can copy all the certificates in one file and use it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Extract .crt and .key files from .pfx file Start OpenSSL from the OpenSSL\\bin folder.Open the command prompt and go to the folder that contains your .pfx file. Run the following command to extract the private key:openssl pkcs12 -in [yourfile.pfx] -nocerts -out [drlive.key]You will be prompted to type the import password. Type the password that you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-mjukvara"],"_links":{"self":[{"href":"https:\/\/inorr.net\/index.php?rest_route=\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inorr.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inorr.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inorr.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inorr.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":3,"href":"https:\/\/inorr.net\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":75,"href":"https:\/\/inorr.net\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/75"}],"wp:attachment":[{"href":"https:\/\/inorr.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inorr.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inorr.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}