< prev index next >
src/share/classes/sun/security/provider/JavaKeyStore.java
Print this page
rev 13649 : 8218553: Enhance keystore load debug output
Reviewed-by: weijun
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -33,10 +33,11 @@
import java.util.*;
import sun.misc.IOUtils;
import sun.security.pkcs.EncryptedPrivateKeyInfo;
import sun.security.pkcs12.PKCS12KeyStore;
+import sun.security.util.Debug;
/**
* This class provides the keystore implementation referred to as "JKS".
*
* @author Jan Luehe
@@ -71,10 +72,11 @@
public DualFormatJKS() {
super("JKS", JKS.class, "PKCS12", PKCS12KeyStore.class);
}
}
+ private static final Debug debug = Debug.getInstance("keystore");
private static final int MAGIC = 0xfeedfeed;
private static final int VERSION_1 = 0x01;
private static final int VERSION_2 = 0x02;
// Private keys and their supporting certificate chains
@@ -640,10 +642,11 @@
MessageDigest md = null;
CertificateFactory cf = null;
Hashtable<String, CertificateFactory> cfs = null;
ByteArrayInputStream bais = null;
byte[] encoded = null;
+ int trustedKeyCount = 0, privateKeyCount = 0;
if (stream == null)
return;
if (password != null) {
@@ -678,11 +681,11 @@
String alias;
tag = dis.readInt();
if (tag == 1) { // private key entry
-
+ privateKeyCount++;
KeyEntry entry = new KeyEntry();
// Read the alias
alias = dis.readUTF();
@@ -727,11 +730,11 @@
// Add the entry to the list
entries.put(alias, entry);
} else if (tag == 2) { // trusted certificate entry
-
+ trustedKeyCount++;
TrustedCertEntry entry = new TrustedCertEntry();
// Read the alias
alias = dis.readUTF();
@@ -762,14 +765,20 @@
// Add the entry to the list
entries.put(alias, entry);
} else {
- throw new IOException("Unrecognized keystore entry");
+ throw new IOException("Unrecognized keystore entry: " +
+ tag);
}
}
+ if (debug != null) {
+ debug.println("JavaKeyStore load: private key count: " +
+ privateKeyCount + ". trusted key count: " + trustedKeyCount);
+ }
+
/*
* If a password has been provided, we check the keyed digest
* at the end. If this check fails, the store has been tampered
* with
*/
< prev index next >