<?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>Codedrop™ Weblog &#187; certificate</title>
	<atom:link href="http://www.codedrop.ca/blog/archives/tag/certificate/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codedrop.ca/blog</link>
	<description>Drop'n some code and other tech tidbits...</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:45:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OpenSSL Certificate Formats / Conversion</title>
		<link>http://www.codedrop.ca/blog/archives/131</link>
		<comments>http://www.codedrop.ca/blog/archives/131#comments</comments>
		<pubDate>Tue, 15 Sep 2009 20:45:55 +0000</pubDate>
		<dc:creator>groll</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://www.codedrop.ca/blog/archives/131</guid>
		<description><![CDATA[This past week has left me having to learn much more about https certificates then I ever thought I would care to know&#8230;&#160;&#160; Here&#8217;s a synopsis of some of the highlights of my learnings as pulled from various resources on the web.
OpenSSL supports several certificate formats. Certificates are based on the DSA signature algorithm and [...]]]></description>
			<content:encoded><![CDATA[<p>This past week has left me having to learn much more about https certificates then I ever thought I would care to know&#8230;&nbsp;&nbsp; Here&#8217;s a synopsis of some of the highlights of my learnings as pulled from various resources on the web.</p>
<p>OpenSSL supports several certificate formats. Certificates are based on the DSA signature algorithm and the RSA algorithm for public-key cryptography according to PKCS algorithms.&nbsp; The certificate format depends on the application, as there is no agreement on file format standards.</p>
<p>Private keys are usually available in the PEM and DER format. The related files have names of the following type:</p>
<p>*key-rsa.pem for pem files<br />*key-rsa.der for der files</p>
<p>For OpenSSL applications, the PEM format should suffice. For Java applications, the DER format might be more suitable for importing the private key and certificates.</p>
<p>For certificates, the available formats are PEM, DER and PKCS12 with file names of the following type:</p>
<p>*cert.pem for pem files<br />*cert.der for der files<br />*cert.p12 for pkcs12 files</p>
<p>In general, the PEM formats are mostly used in the Unix world, PCKS12 in the Microsoft world and DER in the Java world.</p>
<p>Certificate files are ASN.1-encoded objects that may be encrypted according to DES (Data Encryption Standard). The files can optionally be encrypted using a symmetric cipher algorithm, such as 3DES.</p>
<p>An unencrypted PEM file might look something like this:</p>
<p>&nbsp;&nbsp;&nbsp; &#8212;&#8211;BEGIN CERTIFICATE&#8212;&#8211;<br />&nbsp;&nbsp;&nbsp; MB4CGQDUoLoCULb9LsYm5+/WN992xxbiLQlEuIsCAQM=<br />&nbsp;&nbsp;&nbsp; &#8212;&#8211;END CERTIFICATE&#8212;&#8211;</p>
<p>The string beginning with MB4C&#8230; is the Base64-encoded, ASN.1-encoded object.</p>
<p>An encrypted file would have headers describing the type of encryption used, and the initialization vector:</p>
<p>&nbsp;&nbsp;&nbsp; &#8212;&#8211;BEGIN RSA PRIVATE KEY&#8212;&#8211;<br />&nbsp;&nbsp;&nbsp; Proc-Type: 4,ENCRYPTED<br />&nbsp;&nbsp;&nbsp; DEK-Info: DES-EDE3-CBC,C814158661DC1449<br />&nbsp;&nbsp;&nbsp; AFAZFbnQNrGjZJ/ZemdVSoZa3HWujxZuvBHzHNoesxeyqqidFvnydA==<br />&nbsp;&nbsp;&nbsp; &#8212;&#8211;END RSA PRIVATE KEY&#8212;&#8211;</p>
<p>The two headers Proc-Type and DEK-Info declare the type of encryption, and the string starting with AFAZ&#8230; is the Base64-encoded, encrypted, ASN.1-encoded object.</p>
<p>As web browsers make use of Java applications, they import/export certificates in pkcs12 file format, i.e. public and private keys are packed in one single file using the PKCS#12 algorithm. Other applications require the pem format with unpacked public and private keys, thus the user must remember the appropriate file format for each application and must perform format conversions as appropriate.</p>
<p>The following tables report a summary of formats used for INFN-Grid applications and two simple scripts with format conversion commands.</p>
<p>INFN-Grid Certificates Format Summary<br />Certificate Type &nbsp;&nbsp;&nbsp; Certificate Format<br />CA Authority Certificate &nbsp;&nbsp;&nbsp; DER<br />Personal Certificate from CA &nbsp;&nbsp;&nbsp; PKCS12<br />Grid Access Certificate &nbsp;&nbsp;&nbsp; PEM</p>
<p>=========================<br />CONVERT pkcs12 to pem<br />=========================<br />#!/bin/sh<br />echo &#8220;copy your cert to cert.p12 &#8211; then run this script&#8221;<br />openssl pkcs12 -clcerts -nokeys -in cert.p12 -out usercert.pem<br />openssl pkcs12 -nocerts -in cert.p12 -out userkey.pem</p>
<p>=========================<br />CONVERT pem to pkcs12<br />=========================<br />#!/bin/sh<br />echo &#8220;Verify that you are using the correct certificate pair (key/cert)&#8221;<br />openssl pkcs12 -export -out one.identity.neteller.com.p12 -inkey ./one.identity.neteller.com.key -in ./one.identity.neteller.com.cert </p>
<p>** NOTE: specify the -in and -inkey parameters as PEM format files&#8230; </p>
<p>If your running JRockit, you might also be interested in how to <a href="http://publib.boulder.ibm.com/infocenter/iwphelp/v2r5m1/index.jsp?topic=/com.ibm.wcs.ic.doc_2.5.1/infocenter/i_sec_t_updateverisignrootcert.html">update Verisign CA root certificates</a>. </p>
<p>This might be required if you start seeing errors such as this:<br />javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=5d37ff70-843b-8313-8968-e114e42e13b9" /></div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=OpenSSL+Certificate+Formats+%2F+Conversion+http://tqy6o.th8.us" title="Post to Twitter"><img class="nothumb" src="http://www.codedrop.ca/blog/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=OpenSSL+Certificate+Formats+%2F+Conversion+http://tqy6o.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codedrop.ca/blog/archives/131/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
