<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I don't honestly know why the key isn't created as a token key in the first place.  When I put CKA_TOKEN = true into the SoftHSM configuration file, I get an "Object class not supported" error from C_CreateObject.  That is the default case in a switch statement that checks the key type - meaning that the object Java tries to create is not detected as a CKO_PUBLIC_KEY or CKO_PRIVATE_KEY.  When I print out oClass, it is set to 1 (CKO_CERTIFICATE).  </div><div><br></div><div>The error in C_CreateObject does happen at the right place in the Java code though - when I try and set the private key into the key store.  </div><div><br></div><div><div>X509Certificate[] chain = makeCertificateChain(keyPair);</div><div>ks.setKeyEntry("ALIAS-GOES-HERE", pk, "1111".toCharArray(), chain);  // THIS LINE</div></div><div><br></div><div>I suspect the CKO_CERTIFICATE oClass is caused by me calling setKeyEntry and passing in the certificate chain - Java associates Private Keys with Certificates - which of course have the Public Key.  I can try saving my key as a SecretKey rather than a PrivateKey, and see if that helps - then I won't have to store the certificate chain.  I think this will also fail though as a CKO_SECRET_KEY won't pass the switch statement in C_CreateObject.</div><div><br></div><div>It sort of feels like we're working around the way Java just wants to do things -  <a href="http://download.oracle.com/javase/6/docs/api/index.html?java/security/KeyStore.html">http://download.oracle.com/javase/6/docs/api/index.html?java/security/KeyStore.html</a>.  I mean having a common interface to a keystore is nice, but one that does what you want is much better :)</div><div><br></div><div>Thanks for your help!</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>Adam</div><div><br></div><br><div><div>On 15/04/2011, at 2:49 AM, Rickard Bellgrim wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On 14 apr 2011, at 01.15, Adam Knight wrote:<br><br><blockquote type="cite">So my questions are, has anyone successfully created an RSA key on SoftHSM using Java?  Am I missing anything?  Is there a reason C_CopyObject isn't implemented (I suspect it's just not a core function and OpenDNSSEC works fine without it)?<br></blockquote><br>Yes, that function is not needed by OpenDNSSEC. But could be implemented by SoftHSM.<br><br>How come they do not create a token object from the beginning?<br><br>// Rickard<br><br></div></blockquote></div><br><div>
<span><img height="29" width="115" id="f7cf7ca0-ed43-4bb9-ae68-1c961baa7d46" apple-width="yes" apple-height="yes" src="cid:4109830A-4532-4726-9372-80F8830211E6@local.aotea.co.nz"></span><br class="Apple-interchange-newline"><br><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 17px; "><span class="Apple-style-span" style="font-size: 9px; color: rgb(128, 128, 128); "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-size: medium; "><b><font size="1"><span style="font-size: 7pt; ">ADAM_KNIGHT</span></font></b></span></span></span></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 17px; "><span class="Apple-style-span" style="font-size: 9px; "><span class="Apple-style-span" style="font-size: medium; "><font size="1"><span style="font-size: 7pt; "><font class="Apple-style-span" color="#666666">DEVELOPER</font></span></font></span></span></span></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 17px; "><span class="Apple-style-span" style="font-size: 9px; "><span class="Apple-style-span" style="font-size: medium; "><font size="1"><span style="font-size: 7pt; "><font class="Apple-style-span" color="#666666">M +64 21 88 00 03</font></span></font></span></span></span></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 17px; "><span class="Apple-style-span" style="font-size: 9px; "><span class="Apple-style-span" style="font-size: medium; "><font size="1"><span style="font-size: 7pt; "><font class="Apple-style-span" color="#666666">P  +64 9 445 9196</font></span></font></span></span></span></div><div><font class="Apple-style-span" face="Calibri, Verdana, Helvetica, Arial" size="1"><span class="Apple-style-span" style="font-size: 9px; "><font class="Apple-style-span" color="#666666"><br></font></span></font></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 17px; "><span class="Apple-style-span" style="font-size: 9px; "><span class="Apple-style-span" style="font-size: medium; "><font size="1"><span style="font-size: 7pt; "><font class="Apple-style-span" color="#666666">LOFT 01 / 2 QUEENS PARADE</font></span></font></span></span></span></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 9px; "><font class="Apple-style-span" color="#666666">THE WHARF</font></span></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 9px; "><font class="Apple-style-span" color="#666666">PO BOX 32_131 </font></span></div><div><font class="Apple-style-span" face="Calibri, Verdana, Helvetica, Arial" size="1"><span class="Apple-style-span" style="font-size: 9px; "><font class="Apple-style-span" color="#666666"><br></font></span></font></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 17px; "><span class="Apple-style-span" style="font-size: 9px; "><span class="Apple-style-span" style="font-size: medium; "><font size="1"><span style="font-size: 7pt; "><font class="Apple-style-span" color="#666666">DEVONPORT</font></span></font></span></span></span></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 9px; "><font class="Apple-style-span" color="#666666">AUCKLAND</font></span></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 9px; "><font class="Apple-style-span" color="#666666">NEW ZEALAND</font></span></div><div><font class="Apple-style-span" face="Calibri, Verdana, Helvetica, Arial" size="1"><span class="Apple-style-span" style="font-size: 9px; "><br></span></font></div><div><span class="Apple-style-span" style="font-family: Calibri, Verdana, Helvetica, Arial; font-size: 17px; "><span class="Apple-style-span" style="font-size: 9px; "><span class="Apple-style-span" style="font-size: medium; "><font size="1"><span style="font-size: 7pt; "><span class="Apple-style-span" style="font-weight: bold; "><font class="Apple-style-span" color="#40B4D2">AOTEA.CO.NZ</font></span></span></font></span></span></span></div>
</div>
<br></body></html>