Java 运行时错误 SIGBUS iText

标签 java pdf runtime-error itext

我尝试使用 iText 5.5.0 和文档示例进行签名:

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);
}

我收到以下错误。

#
# 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
#

我的java版本是:

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)

我正在使用 Netbeans IDE 7.4 和 JCE 无限强度管辖权策略文件,这些文件在我的/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/security 路径中替换。

我已经从我的终端尝试过“ulimit -c unlimited”命令。

最佳答案

我不知道为什么,我在另一个环境中尝试了我的代码,它给了我一个 BouncyCaSTLe 异常。我将 BC JAR 更改为 1.48 版本,它在我的 Windows 环境中正常工作。在我的 Unix 环境中,我在保存文件时遇到问题。

感谢大家

关于Java 运行时错误 SIGBUS iText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21959898/

相关文章:

java - Jar 文件无法识别 - Maven Artifact 丢失

java - 读取单词的第一个字母并选择其字母表的编号

pdf - 从 A4 页面获取两本 A6 完整小册子序列

javascript - pdfMake javascript pdf内容放错位置

Java 运行时错误

c - 段错误 MPI 创建结构

java - 有 JNDI namespace 约定吗?

java - 用于获取当前 UTC 日期时间的单元测试

perl - 如何判断特定字体是否包含 PDF::API2 中的特定字符

C 检查用户输入错误