<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Armbruster IT Blog &#187; pkcs12</title>
	<atom:link href="http://blog.armbruster-it.de/tag/pkcs12/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.armbruster-it.de</link>
	<description>Real world fun with Java, Grails, Groovy, Zope, Plone, Linux and much others.</description>
	<lastBuildDate>Tue, 11 Oct 2011 11:42:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>remove the passphrase from a pkcs12 certificate</title>
		<link>http://blog.armbruster-it.de/2010/03/remove-the-passphrase-from-a-pkcs12-certificate/</link>
		<comments>http://blog.armbruster-it.de/2010/03/remove-the-passphrase-from-a-pkcs12-certificate/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 10:38:28 +0000</pubDate>
		<dc:creator>Stefan Armbruster</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[pkcs12]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.armbruster-it.de/?p=126</guid>
		<description><![CDATA[PKCS12 defines a file format that contains a private key an a associated certifcate. These files might be used to establish some encrypted data exchange. In the current use case, OpenVPN is used to connect to a remote network. The pkcs12 is being issued by a CA (certificat authority) tool. For security reasons, the private [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://de.wikipedia.org/wiki/PKCS">PKCS12</a> defines a file format that contains a private key an a associated certifcate. These files might be used to establish some encrypted data exchange. In the current use case, <a href="http://openvpn.net/">OpenVPN</a> is used to connect to a remote network. The pkcs12 is being issued by a CA (certificat authority) tool. For security reasons, the private key contained in the pkcs12 is normally protected by a passphrase. This has the downside, that you need to manually type the passphrase whenever you need to establish the connection. But there&#8217;s a way to get around this. <a href="http://www.openssl.org/">OpenSSL</a> is a swiss-army-knife toolkit for managing simply everything in the field of keys and certificates. Since it&#8217;s a command line tool, you need to understand what you&#8217;re doing. So it took me a little to figure out how to remove a passphrase from a given pkcs12 file. Here&#8217;s what I&#8217;ve done:</p>

<div class="wp_syntax"><div class="wp_syntax_download"><div class="wp_syntax_download_filename"><a name="file-%0D%0Aopenssl%20pkcs12%20-in%20protected.p12.orig%20-nodes%20-out%20temp.pem%0D%0A%0D%0Aopenssl%20pkcs12%20-export%20-in%20temp.pem%C2%A0%20-out%20unprotected.p12%0D%0A%0D%0Arm%20temp.pem%0D%0A" href="#file-%0D%0Aopenssl+pkcs12+-in+protected.p12.orig+-nodes+-out+temp.pem%0D%0A%0D%0Aopenssl+pkcs12+-export+-in+temp.pem%C2%A0+-out+unprotected.p12%0D%0A%0D%0Arm+temp.pem%0D%0A" title="
openssl pkcs12 -in protected.p12.orig -nodes -out temp.pem

openssl pkcs12 -export -in temp.pem  -out unprotected.p12

rm temp.pem
">
openssl pkcs12 -in protected.p12.orig -nodes -out temp.pem

openssl pkcs12 -export -in temp.pem  -out unprotected.p12

rm temp.pem
</a></div><div class="wp_syntax_download_actions"><a href="http://blog.armbruster-it.de/wp-content/plugins/wp-syntax-download-extension/wp-syntax-download-extension.php/126/%0D%0Aopenssl%20pkcs12%20-in%20protected.p12.orig%20-nodes%20-out%20temp.pem%0D%0A%0D%0Aopenssl%20pkcs12%20-export%20-in%20temp.pem%C2%A0%20-out%20unprotected.p12%0D%0A%0D%0Arm%20temp.pem%0D%0A">raw</a> <a href="http://blog.armbruster-it.de/wp-content/plugins/wp-syntax-download-extension/wp-syntax-download-extension.php/126/download/%0D%0Aopenssl%20pkcs12%20-in%20protected.p12.orig%20-nodes%20-out%20temp.pem%0D%0A%0D%0Aopenssl%20pkcs12%20-export%20-in%20temp.pem%C2%A0%20-out%20unprotected.p12%0D%0A%0D%0Arm%20temp.pem%0D%0A">download</a></div></div><div class="code"><pre class="bash" style="font-family:monospace;">openssl pkcs12 <span style="color: #660033;">-in</span> protected.p12.orig <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-out</span> temp.pem
 
openssl pkcs12 <span style="color: #660033;">-export</span> <span style="color: #660033;">-in</span> temp.pem  <span style="color: #660033;">-out</span> unprotected.p12
 
<span style="color: #c20cb9; font-weight: bold;">rm</span> temp.pem</pre></div></div>

<p>The first command decrypts the original pkcs12 into a temporary pem file. pem is a base64 encoded format. The second command picks this up and constructs a new pkcs12 file. During this, the new passphrase is asked. By simply typing &#8216;return&#8217; here, it set to nothing. When using unprotected.p12 in the OpenVPN connection, you&#8217;re no longer asked for a passphrase.</p>
<p><strong>A word of warning:</strong> I do not recommend doing this generally. From my perspective it&#8217;s okay, if your unprotected pkcs12 file is protected by other means, e.g. harddisc encryption.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.armbruster-it.de/2010/03/remove-the-passphrase-from-a-pkcs12-certificate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

