证书策略 - 多个策略限定符信息

Certificate policies - multiple policy qualifier info

我正在生成证书策略必须具有多个策略限定符信息的证书。预期的结果是左边的那个。我现在的结果是右边那个

我使用的代码如下。即生成两个证书策略

private CertificatePolicies generateCertificatePolicies(Map<String, String> certificateParameters) {
        PolicyQualifierInfo pqInfo = new PolicyQualifierInfo(certificateParameters.get("PolicyQualifierInfo"));
        PolicyInformation policyInfo = new PolicyInformation(new ASN1ObjectIdentifier(certificateParameters.get("PolicyQualifierInfoOID")), new DERSequence(pqInfo));
        PolicyQualifierInfo pqUserNotice = new PolicyQualifierInfo(
                certificateParameters.get("PolicyQualifierUserNotice"));
        PolicyInformation policyInfo2 = new PolicyInformation(PolicyQualifierId.id_qt_unotice,
                new DERSequence(pqUserNotice));
        PolicyInformation[] certificatePolicies = { policyInfo, policyInfo2 };
        return new CertificatePolicies(certificatePolicies);
    }

这段代码对我有用,希望对你有帮助:

String info[] = {"1.1.1.1.1", "General Policy", "https://your.policy.location.com"};
PolicyInformation pis[] = new PolicyInformation[1]; // Number of certificates policies
ASN1ObjectIdentifier pid = new ASN1ObjectIdentifier(info[0]);
final ASN1EncodableVector v1 = new ASN1EncodableVector();
v1.add(new DERBMPString(info[1]));
PolicyQualifierInfo pqi1 = new PolicyQualifierInfo(PolicyQualifierId.id_qt_unotice, new DERSequence(v1));   // User Notice
final ASN1Encodable[] v2 = new ASN1Encodable[2];
v2[0] = PolicyQualifierId.id_qt_cps;
v2[1] = new DERIA5String(info[2]);
PolicyQualifierInfo pqi2 = PolicyQualifierInfo.getInstance(new DERSequence(v2));                            // CPS Pointer
pi = new PolicyInformation(pid, new DERSequence(new ASN1Encodable[]{pqi2, pqi1}));
pis[i] = pi;
CertificatePolicies policies = new CertificatePolicies(pis);