< 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 ****
/*
! * Copyright (c) 1997, 2018, 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
--- 1,7 ----
/*
! * 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,42 ****
--- 33,43 ----
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,80 ****
--- 72,82 ----
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,649 ****
--- 642,652 ----
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,688 ****
String alias;
tag = dis.readInt();
if (tag == 1) { // private key entry
!
KeyEntry entry = new KeyEntry();
// Read the alias
alias = dis.readUTF();
--- 681,691 ----
String alias;
tag = dis.readInt();
if (tag == 1) { // private key entry
! privateKeyCount++;
KeyEntry entry = new KeyEntry();
// Read the alias
alias = dis.readUTF();
*** 727,737 ****
// Add the entry to the list
entries.put(alias, entry);
} else if (tag == 2) { // trusted certificate entry
!
TrustedCertEntry entry = new TrustedCertEntry();
// Read the alias
alias = dis.readUTF();
--- 730,740 ----
// 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,775 ****
// Add the entry to the list
entries.put(alias, entry);
} else {
! throw new IOException("Unrecognized keystore entry");
}
}
/*
* If a password has been provided, we check the keyed digest
* at the end. If this check fails, the store has been tampered
* with
*/
--- 765,784 ----
// Add the entry to the list
entries.put(alias, entry);
} else {
! 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 >