8293093: NPE in P11KeyStore.getID
Reviewed-by: ascarpino, xuelei
This commit is contained in:
parent
3135914362
commit
8e5d680a98
@ -1444,7 +1444,7 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
throw new KeyStoreException
|
throw new KeyStoreException
|
||||||
("expected but could not find private key " +
|
("expected but could not find private key " +
|
||||||
"with CKA_ID " +
|
"with CKA_ID " +
|
||||||
getID(cka_id));
|
getIDNullSafe(cka_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// next find existing end entity cert
|
// next find existing end entity cert
|
||||||
@ -1454,7 +1454,7 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
throw new KeyStoreException
|
throw new KeyStoreException
|
||||||
("expected but could not find certificate " +
|
("expected but could not find certificate " +
|
||||||
"with CKA_ID " +
|
"with CKA_ID " +
|
||||||
getID(cka_id));
|
getIDNullSafe(cka_id));
|
||||||
} else {
|
} else {
|
||||||
if (replaceCert) {
|
if (replaceCert) {
|
||||||
// replacing existing cert and chain
|
// replacing existing cert and chain
|
||||||
@ -1964,8 +1964,8 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
token.p11.C_DestroyObject(session.id(), h.handle);
|
token.p11.C_DestroyObject(session.id(), h.handle);
|
||||||
if (debug != null) {
|
if (debug != null) {
|
||||||
debug.println("destroyCert destroyed cert with CKA_ID [" +
|
debug.println("destroyCert destroyed cert with CKA_ID [" +
|
||||||
getID(cka_id) +
|
getIDNullSafe(cka_id) +
|
||||||
"]");
|
"]");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} finally {
|
} finally {
|
||||||
@ -1999,7 +1999,7 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
if (debug != null) {
|
if (debug != null) {
|
||||||
debug.println("destroyChain destroyed end entity cert " +
|
debug.println("destroyChain destroyed end entity cert " +
|
||||||
"with CKA_ID [" +
|
"with CKA_ID [" +
|
||||||
getID(cka_id) +
|
getIDNullSafe(cka_id) +
|
||||||
"]");
|
"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2124,7 +2124,7 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
if (debug != null) {
|
if (debug != null) {
|
||||||
debug.println
|
debug.println
|
||||||
("destroyPkey did not find private key with CKA_ID [" +
|
("destroyPkey did not find private key with CKA_ID [" +
|
||||||
getID(cka_id) +
|
getIDNullSafe(cka_id) +
|
||||||
"]");
|
"]");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2169,6 +2169,13 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Null safe version of getID.
|
||||||
|
*/
|
||||||
|
private static String getIDNullSafe(byte[] bytes) {
|
||||||
|
return (bytes != null) ? getID(bytes) : "null";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find an object on the token
|
* find an object on the token
|
||||||
*
|
*
|
||||||
@ -2205,12 +2212,12 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
} else if (type == ATTR_CLASS_CERT) {
|
} else if (type == ATTR_CLASS_CERT) {
|
||||||
debug.println
|
debug.println
|
||||||
("getTokenObject did not find cert with CKA_ID [" +
|
("getTokenObject did not find cert with CKA_ID [" +
|
||||||
getID(cka_id) +
|
getIDNullSafe(cka_id) +
|
||||||
"]");
|
"]");
|
||||||
} else {
|
} else {
|
||||||
debug.println("getTokenObject did not find private key " +
|
debug.println("getTokenObject did not find private key " +
|
||||||
"with CKA_ID [" +
|
"with CKA_ID [" +
|
||||||
getID(cka_id) +
|
getIDNullSafe(cka_id) +
|
||||||
"]");
|
"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2253,13 +2260,13 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
"found " +
|
"found " +
|
||||||
h.length +
|
h.length +
|
||||||
" certificates sharing CKA_ID " +
|
" certificates sharing CKA_ID " +
|
||||||
getID(cka_id));
|
getIDNullSafe(cka_id));
|
||||||
} else {
|
} else {
|
||||||
throw new KeyStoreException("invalid KeyStore state: " +
|
throw new KeyStoreException("invalid KeyStore state: " +
|
||||||
"found " +
|
"found " +
|
||||||
h.length +
|
h.length +
|
||||||
" private keys sharing CKA_ID " +
|
" private keys sharing CKA_ID " +
|
||||||
getID(cka_id));
|
getIDNullSafe(cka_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new THandle(NO_HANDLE, null);
|
return new THandle(NO_HANDLE, null);
|
||||||
@ -2515,7 +2522,7 @@ final class P11KeyStore extends KeyStoreSpi {
|
|||||||
if (debug != null) {
|
if (debug != null) {
|
||||||
debug.println
|
debug.println
|
||||||
("did not find match for private key with CKA_ID [" +
|
("did not find match for private key with CKA_ID [" +
|
||||||
getID(pkeyID) +
|
getIDNullSafe(pkeyID) +
|
||||||
"] (ignoring entry)");
|
"] (ignoring entry)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user