mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-18 23:19:33 +00:00
8277224: sun.security.pkcs.PKCS9Attributes.toString() throws NPE
Reviewed-by: weijun
This commit is contained in:
parent
d8c0280273
commit
6bb04626af
@ -275,11 +275,13 @@ public class PKCS9Attributes {
|
||||
*/
|
||||
public PKCS9Attribute[] getAttributes() {
|
||||
PKCS9Attribute[] attribs = new PKCS9Attribute[attributes.size()];
|
||||
ObjectIdentifier oid;
|
||||
|
||||
int j = 0;
|
||||
for (int i=1; i < PKCS9Attribute.PKCS9_OIDS.length &&
|
||||
j < attribs.length; i++) {
|
||||
if (PKCS9Attribute.PKCS9_OIDS[i] == null) {
|
||||
continue;
|
||||
}
|
||||
attribs[j] = getAttribute(PKCS9Attribute.PKCS9_OIDS[i]);
|
||||
|
||||
if (attribs[j] != null)
|
||||
@ -323,11 +325,13 @@ public class PKCS9Attributes {
|
||||
StringBuilder sb = new StringBuilder(200);
|
||||
sb.append("PKCS9 Attributes: [\n\t");
|
||||
|
||||
ObjectIdentifier oid;
|
||||
PKCS9Attribute value;
|
||||
|
||||
boolean first = true;
|
||||
for (int i = 1; i < PKCS9Attribute.PKCS9_OIDS.length; i++) {
|
||||
if (PKCS9Attribute.PKCS9_OIDS[i] == null) {
|
||||
continue;
|
||||
}
|
||||
value = getAttribute(PKCS9Attribute.PKCS9_OIDS[i]);
|
||||
|
||||
if (value == null) continue;
|
||||
@ -338,7 +342,7 @@ public class PKCS9Attributes {
|
||||
else
|
||||
sb.append(";\n\t");
|
||||
|
||||
sb.append(value.toString());
|
||||
sb.append(value);
|
||||
}
|
||||
|
||||
sb.append("\n\t] (end PKCS9 Attributes)");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7180907
|
||||
* @bug 7180907 8277224
|
||||
* @summary Jarsigner -verify fails if rsa file used sha-256 with authenticated attributes
|
||||
* @modules java.base/sun.security.pkcs
|
||||
* java.base/sun.security.tools.keytool
|
||||
@ -60,8 +60,13 @@ public class NonStandardNames {
|
||||
PKCS9Attributes authed = new PKCS9Attributes(new PKCS9Attribute[]{
|
||||
new PKCS9Attribute(PKCS9Attribute.CONTENT_TYPE_OID, ContentInfo.DATA_OID),
|
||||
new PKCS9Attribute(PKCS9Attribute.MESSAGE_DIGEST_OID, md.digest(data)),
|
||||
new PKCS9Attribute(PKCS9Attribute.SIGNATURE_TIMESTAMP_TOKEN_OID, "test".getBytes())
|
||||
});
|
||||
|
||||
// test PKCS9Attributes.toString(), PKCS9Attributes.getAttributes()
|
||||
System.out.println(authed);
|
||||
authed.getAttributes();
|
||||
|
||||
Signature s = Signature.getInstance("SHA256withRSA");
|
||||
s.initSign(cakg.getPrivateKey());
|
||||
s.update(authed.getDerEncoding());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user