src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, 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

@@ -1640,11 +1640,11 @@
 
             String alias = e.nextElement();
             Entry entry = entries.get(alias);
 
             // certificate chain
-            int chainLen = 1;
+            int chainLen = 0;
             Certificate[] certs = null;
 
             if (entry instanceof PrivateKeyEntry) {
                 PrivateKeyEntry keyEntry = (PrivateKeyEntry) entry;
                     if (keyEntry.chain == null) {

@@ -1654,10 +1654,11 @@
                     }
                 certs = keyEntry.chain;
 
             } else if (entry instanceof CertEntry) {
                certs = new Certificate[]{((CertEntry) entry).cert};
+               chainLen = 1;
             }
 
             for (int i = 0; i < chainLen; i++) {
                 // create SafeBag of Type CertBag
                 DerOutputStream safeBag = new DerOutputStream();