You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PGPainless SOP加密文件抛UnacceptableSelfSignatureException异常求助

使用PGPainless SOP 1.6.6加密失败,收件人公钥无过期日期

我用PGPainless SOP(1.6.6版本)做文件加密和签名操作,所用私钥、公钥均由客户提供。收件人的公钥未设置过期日期,但我实在搞不懂这为何会导致加密失败,有没有人遇到过类似问题?

我已经尝试了以下操作:

  • 查阅资料,未发现加密文件必须要求公钥设置过期日期的相关说明;
  • 分别尝试加密并签名、仅加密两种方式,均以失败告终;
  • 使用相同密钥在Mac应用GPG Keychain中可正常完成加密与签名操作。

相关代码如下:

/*
 * Recipients are found within conf_pgp/recipients
 * 
 */

byte[] recpKey = this.loadKey(Paths.get(getRecipientfolder(), recipientKeyName).toString());
byte[] signKey = null;

String signPwd2Use = signKeyPasswd;
/*
 * Signing key
 */
if(sign) {
    if(signKeyPath.isBlank() || signKeyPath.equals(this.secretKeyPath)) {
        signKey = this.secretKey;
        signPwd2Use = this.secretKeyPassphrase;
    }else {         
        signKey = this.loadKey(Paths.get(signKeyPath).toString());
    }           
}

/*
 * Streams
 */
FileInputStream iStm = null;
FileOutputStream oStm = null;

File outF = new File(outputPath);
if (outF.exists()) {
    try {
        Files.delete(Paths.get(outputPath));
    } catch (IOException e) {
        new ExceptionUtils("PgpTools", "decrypt", appLogger).logIt(e);
    }
}

try {

    //..Read the file in via input stream
    //byte[] plainText = Files.readAllBytes(Paths.get(sourcePath));
    iStm = new FileInputStream(Paths.get(sourcePath).toFile());
    oStm = new FileOutputStream(Paths.get(outputPath).toFile());
    if(sign) {

        sop.encrypt()
            
        //..recipients
        .withCert(recpKey)
            
        //..signing
        .signWith(signKey)              
        //.si(signPwd2Use)
            
        .plaintext(iStm)                
        .writeTo(oStm);

    }else {
        sop.encrypt()
            
        .withCert(recpKey)
            
        .plaintext(iStm)                    
        .writeTo(oStm);

    }

    appLogger.debug("** Encrypted file (PGP)  [" + sourcePath + "] to [" + outputPath + "]");
    
    return true;

} catch (Exception e) {
    // 此处省略异常处理代码
}

内容的提问来源于stack exchange,提问作者MarkB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 10:12:35