<?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>Berthou.com &#187; certificat</title>
	<atom:link href="http://www.berthou.com/us/tag/certificat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.berthou.com/us</link>
	<description>A french developper blog</description>
	<lastBuildDate>Mon, 09 Aug 2010 08:55:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Verify PDF signature with iText</title>
		<link>http://www.berthou.com/us/2009/07/01/verify-pdf-signature-with-itext/</link>
		<comments>http://www.berthou.com/us/2009/07/01/verify-pdf-signature-with-itext/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 17:56:39 +0000</pubDate>
		<dc:creator>rberthou</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[certificat]]></category>
		<category><![CDATA[pdf]]></category>

		<guid isPermaLink="false">http://www.berthou.com/us/?p=54</guid>
		<description><![CDATA[Description After the article &#8220;How to sign a PDF in Java&#8221; I had various demands concerning the verification of this signature. You will find in this article an exemple of code which permit to check this. Tools used http://itextpdf.sourceforge.net/howtosign.html#howtoverify : Origins of the informations and of the code used below Acrobat reader 8.x ou sup [...]]]></description>
				<content:encoded><![CDATA[<h2 class="titre2">Description</h2>
<p><img src="/_img/pdf_sign.png" class="left"/><br />
After the article &#8220;How to sign a PDF in Java&#8221; I had various demands concerning the verification of this signature.<br />
You will find in this article an exemple of code which permit to check this.</p>
<h2 class="titre2">Tools used</h2>
<ul>
<li><a href="http://itextpdf.sourceforge.net/howtosign.html" target="_new">http://itextpdf.sourceforge.net/howtosign.html#howtoverify</a> : Origins of the informations and of the code used below</li>
<li><a href="http://www.adobe.com/fr/products/acrobat/" target="_blank">Acrobat reader 8.x ou sup</a> To read the PDF documents</li>
<li><a href="http://www.lowagie.com/iText/" target="_blank">iText 2.x</a>Java librarie tools (the reference according to me) to create, sign and handle PDF documents</li>
<li><a href="http://www.bouncycastle.org/fr/index.html" target="_blank">bouncycastle.org</a> used in itext (bcprov)</li>
</ul>
<p><span id="more-54"></span></p>
<h2 class="titre2">Exemple (source code)</h2>
<p>As you can see the java code to do this is very simple :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.berthou.test.pdf</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.security.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.security.cert.Certificate</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.pdf.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> test_pdf  <span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Name of the PDF document
	 */</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> dirname  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;D:<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span> <span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// &quot;D:\\&quot;</span>
	<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> fname  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;HelloWorld_sign&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			test_pdf.<span style="color: #006633;">verifyPdf</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">boolean</span> verifyPdf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                   <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>, DocumentException, <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">KeyStore</span> kall <span style="color: #339933;">=</span> PdfPKCS7.<span style="color: #006633;">loadCacertsKeyStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		PdfReader reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfReader<span style="color: #009900;">&#40;</span>dirname <span style="color: #339933;">+</span> fname <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;.pdf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		AcroFields af <span style="color: #339933;">=</span> reader.<span style="color: #006633;">getAcroFields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Search of the whole signature</span>
		<span style="color: #003399;">ArrayList</span> names <span style="color: #339933;">=</span> af.<span style="color: #006633;">getSignatureNames</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// For every signature :</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> k <span style="color: #339933;">&lt;</span> names.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>k<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		   <span style="color: #003399;">String</span> name <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span>names.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>k<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  		   <span style="color: #666666; font-style: italic;">// Affichage du nom</span>
		   <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Signature name: &quot;</span> <span style="color: #339933;">+</span> name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Signature covers whole document: &quot;</span>
                                <span style="color: #339933;">+</span> af.<span style="color: #006633;">signatureCoversWholeDocument</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  		   <span style="color: #666666; font-style: italic;">// Affichage sur les revision - version</span>
		   <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Document revision: &quot;</span> <span style="color: #339933;">+</span> af.<span style="color: #006633;">getRevision</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; of &quot;</span>
                                <span style="color: #339933;">+</span> af.<span style="color: #006633;">getTotalRevisions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #666666; font-style: italic;">// Debut de l'extraction de la &quot;revision&quot;</span>
		   <span style="color: #003399;">FileOutputStream</span> out <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d:<span style="color: #000099; font-weight: bold;">\\</span>revision_&quot;</span>
                                <span style="color: #339933;">+</span> af.<span style="color: #006633;">getRevision</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.pdf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #000066; font-weight: bold;">byte</span> bb<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8192</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		   <span style="color: #003399;">InputStream</span> ip <span style="color: #339933;">=</span> af.<span style="color: #006633;">extractRevision</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		   <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>n <span style="color: #339933;">=</span> ip.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span>bb<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> out.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>bb, <span style="color: #cc66cc;">0</span>, n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   out.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   ip.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #666666; font-style: italic;">// Fin extraction revision</span>
&nbsp;
		   PdfPKCS7 pk <span style="color: #339933;">=</span> af.<span style="color: #006633;">verifySignature</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #003399;">Calendar</span> cal <span style="color: #339933;">=</span> pk.<span style="color: #006633;">getSignDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #003399;">Certificate</span> pkc<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> pk.<span style="color: #006633;">getCertificates</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #666666; font-style: italic;">// Information about the certificat, le signataire</span>
		   <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Subject: &quot;</span>
                                <span style="color: #339933;">+</span> PdfPKCS7.<span style="color: #006633;">getSubjectFields</span><span style="color: #009900;">&#40;</span>pk.<span style="color: #006633;">getSigningCertificate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #666666; font-style: italic;">// Le document à t'il ete modifié ?</span>
		   <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Document modified: &quot;</span> <span style="color: #339933;">+</span> <span style="color: #339933;">!</span>pk.<span style="color: #006633;">verify</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		   <span style="color: #666666; font-style: italic;">// Is the certificate avaible ? Be carefull we search the chain of certificat</span>
		   <span style="color: #003399;">Object</span> fails<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> PdfPKCS7.<span style="color: #006633;">verifyCertificates</span><span style="color: #009900;">&#40;</span>pkc, kall, <span style="color: #000066; font-weight: bold;">null</span>, cal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fails <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		       <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Certificates verified against the KeyStore&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #000000; font-weight: bold;">else</span>
		       <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Certificate failed: &quot;</span> <span style="color: #339933;">+</span> fails<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2 class="titre2">Sample PDF generate</h2>
<p class="alertDownload">
<a href="/download.php?type=wp&#038;file=HelloWorld_sign.pdf" target="_blank">HelloWorld_sign.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.berthou.com/us/2009/07/01/verify-pdf-signature-with-itext/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MS CAPI and Java (JCE SunMSCAPI)</title>
		<link>http://www.berthou.com/us/2007/12/05/ms-capi-and-java-jce-sunmscapi/</link>
		<comments>http://www.berthou.com/us/2007/12/05/ms-capi-and-java-jce-sunmscapi/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 21:20:37 +0000</pubDate>
		<dc:creator>rberthou</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[certificat]]></category>
		<category><![CDATA[jce]]></category>

		<guid isPermaLink="false">http://www.berthou.com/us/2007/12/05/ms-capi-and-java-jce-sunmscapi/</guid>
		<description><![CDATA[Description This news is the following of &#8220;How to signing a PDF with Java&#8221; I continu my research to use certificate available in the MS Windows Keystrore.I wanted to use a certificate stored in a card (use for MS Windows signe on). Thanks to these researchs I discovered that with JDK 6 it is very [...]]]></description>
				<content:encoded><![CDATA[<h2 class="titre2">Description</h2>
<p>This news is the following of <a href="http://www.berthou.com/us/?p=18">&#8220;How to signing a PDF with Java&#8221;</a><br />
<br/><br />
I continu my research to use certificate available in the MS Windows Keystrore.I wanted to use a certificate stored in a card (use for MS Windows signe on).<br />
<br/><br />
Thanks to these researchs I discovered that with JDK 6 it is very simple to  use the <a href="http://en.wikipedia.org/wiki/Cryptographic_API" target="_blank"><b>MSCAPI</b></a>&#8216;s API .<br />
<span id="more-23"></span><br />
With Java SE 6 you have a large choice of tools and it is configurate with most of crypto &#8220;providers&#8221; as <b>SunMSCAPI Provider</b> (see $JRE_HOME/lib/security/java.security ).</p>
<pre class="alertCode">
#
# List of providers and their preference orders (see above):
#
security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.sun.net.ssl.internal.ssl.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
security.provider.6=com.sun.security.sasl.Provider
security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.8=sun.security.smartcardio.SunPCSC
security.provider.9=sun.security.mscapi.SunMSCAPI
</pre>
<h2 class="titre2">Services supported by SunMSCAPI</h2>
<table class=tbl0>
<thead class="rh">
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="r1">
<td>KeyPairGenerator</td>
<td>
<ul>
<li>RSA</li>
</ul>
</td>
<td>Generates RSA key pairs needed by other cryptographic services such as Signature and Cipher.</td>
</tr>
<tr class="r2">
<td>Signature</td>
<td>
<ul>
<li>SHA1withRSA</li>
<li>MD5withRSA</li>
<li>MD2withRSA</li>
</ul>
</td>
<td>Creates and validates signatures using various message digest and encryption algorithm as specified in the service name.</td>
</tr>
<tr class="r1">
<td>Cipher</td>
<td>
<ul>
<li>RSA</li>
<li>RSA/ECB/PKCS1Padding</li>
</ul>
</td>
<td>Performs RSA encryption and decryption.</td>
</tr>
<tr class="r2">
<td>KeyStore</td>
<td>
<ul>
<li>Windows-MY</li>
<li>Windows-ROOT</li>
</ul>
</td>
<td>Provides direct read-write access to MS Window&#8217;s keystores. The Windows-MY keystore contains the user&#8217;s private keys and the associated certificate chains. The Windows-ROOT keystore contains all root CA certificates trusted by the machine.</td>
</tr>
<tr class="r1">
<td>SecureRandom</td>
<td>
<ul>
<li>Windows-PRNG</li>
</ul>
</td>
<td>Generates random numbers for the random data that other cryptographic services need.</td>
</tr>
</tbody>
</table>
<p class="alertWarning">
Warning :By using this API I saw that the PIN&#8217;s code is asked even if you pass it in the code.  (I think it should be a bug in drivers card readers) .
</p>
<p><br/></p>
<h2 class="titre2">Exemple</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">KeyStore</span> ks <span style="color: #339933;">=</span> <span style="color: #003399;">KeyStore</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Windows-ROOT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	ks.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	java.<span style="color: #006633;">util</span>.<span style="color: #003399;">Enumeration</span> en <span style="color: #339933;">=</span> ks.<span style="color: #006633;">aliases</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>en.<span style="color: #006633;">hasMoreElements</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span> aliasKey <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span>en.<span style="color: #006633;">nextElement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
		<span style="color: #003399;">Certificate</span> c <span style="color: #339933;">=</span> ks.<span style="color: #006633;">getCertificate</span><span style="color: #009900;">&#40;</span>aliasKey<span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;---&gt; alias : &quot;</span> <span style="color: #339933;">+</span> sss<span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;    Certificat : &quot;</span> <span style="color: #339933;">+</span> c.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aliasKey.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;myKey&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		      <span style="color: #003399;">PrivateKey</span> key <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">PrivateKey</span><span style="color: #009900;">&#41;</span>ks.<span style="color: #006633;">getKey</span><span style="color: #009900;">&#40;</span>aliasKey, <span style="color: #0000ff;">&quot;monPassword&quot;</span>.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		      <span style="color: #003399;">Certificate</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> chain <span style="color: #339933;">=</span> ks.<span style="color: #006633;">getCertificateChain</span><span style="color: #009900;">&#40;</span>aliasKey<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ioe<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>ioe.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p class="alertLink">
<b>Voir aussi</b><br />
<a href="http://java.sun.com/developer/technicalArticles/J2SE/security/" target="_blank">http://java.sun.com/developer/technicalArticles/J2SE/security/</a><br />
<a href="http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html" target="_blank">http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.berthou.com/us/2007/12/05/ms-capi-and-java-jce-sunmscapi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
