Pheox - Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Problem sign documento RSS feed
Forum Index » General Issues
Author Message
javimartinez

Visitor

Joined: Oct 14, 2008
Messages: 1
Offline
Hello,

We are using JCAPI 1.2 to sign PDF documents with a applet. It has been working ok for one year, but now we have a exception in the computer of a new user. The exception is:


com.pheox.jcapi.JCAPIJNIRuntimeException: Exception raised in JCAPI.DLL:
JCAPISignature_sign() - Could not acquire a key container handle.
at com.pheox.jcapi.CoreSignatureJNI.sign(Native Method)
at com.pheox.jcapi.h.b(Unknown Source)
at com.pheox.jcapi.l.engineSign(Unknown Source)
at java.security.Signature$Delegate.engineSign(Unknown Source)
at java.security.Signature.sign(Unknown Source)
at com.lowagie.text.pdf.PdfPKCS7.getEncodedPKCS7(Unknown Source)
at com.lowagie.text.pdf.PdfPKCS7.getEncodedPKCS7(Unknown Source)
at com.lowagie.text.pdf.PdfSigGenericPKCS.setSignInfo(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
at com.lowagie.text.pdf.PdfStamper.close(Unknown Source)
at es.com.mipaquete.appletFirma.AppletFirmaJCAPI.signDoc(AppletFirmaJCAPI.java:217)
at es.com.mipaquete.appletFirma.AppletFirmaJCAPI.firmar(AppletFirmaJCAPI.java:192)
at es.com.mipaquete.appletFirma.AppletFirmaJCAPI.firmarDocumentos(AppletFirmaJCAPI.java:161)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)


however, we have accessed to key container before to shows to the user the certificates he can select.

The code that cause the error (and work in others computers) is:


private String signDoc(String doc, String razon, String lugar) throws Exception
{
byte[] bytes = doc.getBytes();
byte[] decoded = Base64Util.decode(bytes);
PrivateKey key = (PrivateKey)ks.getKey(aliasSeleccionado, null);
Certificate[] chain = ks.getCertificateChain(aliasSeleccionado);
PdfReader reader = new PdfReader(decoded);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfStamper stp = PdfStamper.createSignature(reader, baos, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason(razon);
sap.setLocation(lugar);
stp.close();
byte[] signedBytes = Base64Util.encode(baos.toByteArray());
String res = new String(signedBytes);
return res;
}


(the line is "stp.close();")


The only difference between the computer of this user is that it goes with Java Virtual Machine 1.5._07, that is oldest than other user“s virtual machine

Thanks and sorry bad english
 
Forum Index » General Issues
Go to:   
Mobile view
Powered by JForum 2.8.3 © 2023 JForum Team • Maintained by Andowson Chang and Ulf Dittmer