【问题标题】:Misspelling instructions when migrating from BouncyCastle bcprov-jdk15on 1.62 to v1.69从 BouncyCastle bcprov-jdk15on 1.62 迁移到 v1.69 时出现拼写错误说明
【发布时间】:2022-11-03 23:18:22
【问题描述】:

我有一个使用 BouncyCastle bcprov-jdk15on 1.62 版的 Java 应用程序。我将展示以下源代码:

Pom 文件:

<dependencies>
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk15on</artifactId>
        <version>1.62</version>    
        <scope>provided</scope>   
    </dependency>
</dependencies>

企业社会责任.java

import org.bouncycastle.asn1.DEROutputStream;
    
...

public String createSigningRequest(String signAlgorithm, String subject, PublicKey publicKey, PrivateKey privateKey, String provName) {
    StringBuilder sb = null;
    try {
                                    sb      = new StringBuilder();
        X509Name                    xname   = new X509Name(subject);
        PKCS10CertificationRequest  csr     = new PKCS10CertificationRequest(signAlgorithm, xname, publicKey , null, privateKey, provName);
        ByteArrayOutputStream       baos    = new ByteArrayOutputStream();
        DEROutputStream             deros   = new DEROutputStream(baos);
        deros.writeObject(csr.toASN1Primitive());
        String                      sTmp    = new String(org.bouncycastle.util.encoders.Base64.encode(baos.toByteArray()));
        
        sb.append(HEADER_CSR_PEM);
        for (int iCnt=0; iCnt < sTmp.length(); iCnt+=CERT_REQ_LINE_LENGTH) {
            int iLineLength;
            if ((iCnt + CERT_REQ_LINE_LENGTH) > sTmp.length()) {
                iLineLength=sTmp.length() - iCnt;
            }
            else {
                iLineLength=CERT_REQ_LINE_LENGTH;
            }
            sb.append(sTmp.substring(iCnt,iCnt + iLineLength)).append("\n");
        }
        sb.append(FOOTER_CSR_PEM);
        return sb.toString();
    } catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidKeyException | SignatureException | IOException ex) {
        errorMessage = ex.getLocalizedMessage();
        LOG.error("createSigningRequest : " + ex.getLocalizedMessage());
    }

    return "";
}

另一方面,来自 Maven 存储库的 BouncyCastle bcprov-jdk15on 1.69。所以我用这个新版本升级了pom文件。即使,我有以下拼写错误说明:

import org.bouncycastle.asn1.DEROutputStream;  //DEROutputStream is not public in org.bouncycastle.asn1; cannot be accessed from outside package
...
DEROutputStream             deros   = new DEROutputStream(baos);   //DEROutputStream is not public in org.bouncycastle.asn1; cannot be accessed from outside package
...
} catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidKeyException | SignatureException | IOException ex) {   //exception IOException is never thrown in body of corresponding try statement

这三个指令不被识别。我的问题是根据 bcprov-jdk15on 1.69 更改的新指令是什么?

  • 添加:“当我使用 jdk 1.8u341 部署到 Wildfly 10 时出错”

我收到以下错误:

Cannot upload deployment: 
{"WFLYCTL0080: Failed services" => 
    {"jboss.undertow.deployment.default-server.default-host./myJavaApp" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./myJavaApp: java.lang.ArrayIndexOutOfBoundsException: 51201 
        Caused by: java.lang.ArrayIndexOutOfBoundsException: 51201"},
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./myJavaApp"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}

【问题讨论】:

    标签: java cryptography bouncycastle pki


    【解决方案1】:

    如果您查看documentation of DEROutputStream,那么您可以阅读构造函数的以下文本(我指出了 1.66,但它也已经在 1.64 中,并且可能在之前):

    已弃用。ASN1OutputStream.create(OutputStream, String)ASN1Encoding.DER 一起使用。

    是的,对 Bouncy 的轻量级 API 的更改有点烦人,整个类可能应该已经被弃用了。

    【讨论】:

    • 我正在测试你说的。我的 netbeans 与 jdk 1.8u341 相关联。我在源代码中将其更改为 ANS1OutputStream。然后我正在调试,我看到它在我的电脑上工作。尽管如此,我还是无法使用 Wildfly 10 和 Java 1.8u341 在测试服务器上部署该应用程序。我将在上面的帖子中将错误写为已添加:“使用 jdk 1.8u341 部署到 Wildfly 10 时出错”
    猜你喜欢
    • 2015-06-24
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    • 2017-10-04
    • 1970-01-01
    相关资源
    最近更新 更多