{"id":2377,"date":"2015-12-02T14:42:46","date_gmt":"2015-12-02T14:42:46","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=2377"},"modified":"2015-12-03T07:31:58","modified_gmt":"2015-12-03T07:31:58","slug":"private-key-from-exported-p12-file","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=2377","title":{"rendered":"Private key from exported P12 file"},"content":{"rendered":"<p>Very useful for POUND proxys and OS X CA&#8217;s<\/p>\n<p>As a side note, to export a Private key from OS X keychain you must select BOTH the private key and the certificate it is linked too. \u00a0Easiest way to do this is view the keys, then swing down the arrow next to the key you want to show the Certificate. \u00a0Select BOTH and then right click and chose Export. This will produce a P12 file with the Certificate and Private key.<\/p>\n<p>You can use following commands to extract public\/private key from a PKCS#12 container:<\/p>\n<p>Private key:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">openssl pkcs12 -in yourP12File.pfx -nocerts -out privateKey.pem<\/div><\/div>\n<p>Certificates:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">openssl pkcs12 -in yourP12File.pfx -clcerts -nokeys -out publicCert.pem<\/div><\/div>\n<p>To extract the private key in a format openssh can use:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">openssl pkcs12 -in pkcs12.pfx -nocerts -nodes | openssl rsa &amp;gt; private.key<\/div><\/div>\n<p>To convert the private key to a public key:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">openssl rsa -in id_rsa -pubout | ssh-keygen -f \/dev\/stdin -i -m PKCS8<\/div><\/div>\n<p>To extract the public key in a format openssh can use:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">openssl pkcs12 -in pkcs12.pfx -clcerts -nokeys | openssl x509 -pubkey -noout | ssh-keygen -f \/dev\/stdin -i -m PKCS8<\/div><\/div>\n<p>To Convert to a PEM including private keys<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">openssl pkcs12 -in file-to-convert.p12 -out converted-file.pem -nodes<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Very useful for POUND proxys and OS X CA&#8217;s As a side note, to export a Private key from OS X keychain [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2377","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2377"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2377\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}