0

I'm trying to sign using iText 5.5.0 with the documentation example:

private static void pdfSign(String srcFile, String dstFile) throws Exception

    KeyStore ks = KeyStore.getInstance("pkcs12", "BC");
    ks.load(new FileInputStream(PFX_ROUTE), PFX_PASSPHRASE);
    String alias = (String)ks.aliases().nextElement();
    PrivateKey pk = (PrivateKey)ks.getKey(alias, KEY_PASSPHRASE);
    Certificate[] chain = ks.getCertificateChain(alias);
    // reader and stamper
    PdfReader reader = new PdfReader(srcFile);
    PdfStamper stamper = PdfStamper.createSignature(reader, new FileOutputStream(dstFile), '\0');
    // appearance
    PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
    appearance.setVisibleSignature(SIGNFIELD_NAME);
    appearance.setReason("Test");
    appearance.setLocation("TestLocation");


    ExternalSignature es = new PrivateKeySignature(pk, "SHA-1", "BC");
    ExternalDigest digest = new BouncyCastleDigest();
    MakeSignature.signDetached(appearance, digest, es, chain, null, null, null, 0, CryptoStandard.CMS);
}

I am getting the following error.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0xa) at pc=0x00007fff943f8be0, pid=602, tid=6403
#
# JRE version: Java(TM) SE Runtime Environment (7.0_45-b18) (build 1.7.0_45-b18)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.45-b08 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libsystem_platform.dylib+0x3be0]  _platform_memmove$VARIANT$Unknown+0xe0
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit                 -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/twofaz/Documents/Development/Clarice/Clarice.iText5/hs_err_pid602.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

My java version is:

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

I am using Netbeans IDE 7.4 and the JCE Unlimited Strength Jurisdiction Policy Files substituted in my /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/security path.

I already tried the: "ulimit -c unlimited" command from my terminal.

5
  • Please show the contents of hs_err_pid602.log. Commented Feb 22, 2014 at 20:37
  • Added the contents here: dl.dropboxusercontent.com/u/20061552/hs_err_pid602.log Commented Feb 22, 2014 at 20:52
  • Hhmmm, sun.misc.Unsafe.copyMemory often seems to be involved in interesting JVM crashes. You might want to try a different PdfReader constructor, e.g. first reading the file into memory and then using the constructor with a byte[] argument. Commented Feb 22, 2014 at 22:33
  • Did try it that way, still same error. Commented Feb 23, 2014 at 17:29
  • 1
    Alternatively, have you tried a different jvm version? As iTextin your use case does only use standard api calls, this most likely is a Java error. Commented Feb 23, 2014 at 18:04

1 Answer 1

1

I don't know why it was, I tried my code on another environment and it gave me a BouncyCastle Exception. I changed the BC JAR to the 1.48 version and it worked correctly on my Windows Environment. On my Unix environment I am having problems to save the file.

Thanks to all

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.