--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java Tue Aug 11 12:20:32 2009 +0800
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java Tue Aug 11 15:36:52 2009 +0800
@@ -880,41 +880,41 @@
// might not work properly, since -gencert is slow
// and there's no data in the pipe at the beginning.
ByteArrayOutputStream bout = new ByteArrayOutputStream();
- byte[] b = new byte[4096];
- while (true) {
- int len = inStream.read(b);
- if (len < 0) break;
- bout.write(b, 0, len);
- }
- inStream = new ByteArrayInputStream(bout.toByteArray());
try {
- String importAlias = (alias!=null)?alias:keyAlias;
- if (keyStore.entryInstanceOf(importAlias, KeyStore.PrivateKeyEntry.class)) {
- kssave = installReply(importAlias, inStream);
- if (kssave) {
- System.err.println(rb.getString
- ("Certificate reply was installed in keystore"));
- } else {
- System.err.println(rb.getString
- ("Certificate reply was not installed in keystore"));
- }
- } else if (!keyStore.containsAlias(importAlias) ||
- keyStore.entryInstanceOf(importAlias,
- KeyStore.TrustedCertificateEntry.class)) {
- kssave = addTrustedCert(importAlias, inStream);
- if (kssave) {
- System.err.println(rb.getString
- ("Certificate was added to keystore"));
- } else {
- System.err.println(rb.getString
- ("Certificate was not added to keystore"));
- }
+ byte[] b = new byte[4096];
+ while (true) {
+ int len = inStream.read(b);
+ if (len < 0) break;
+ bout.write(b, 0, len);
}
} finally {
if (inStream != System.in) {
inStream.close();
}
}
+ inStream = new ByteArrayInputStream(bout.toByteArray());
+ String importAlias = (alias!=null)?alias:keyAlias;
+ if (keyStore.entryInstanceOf(importAlias, KeyStore.PrivateKeyEntry.class)) {
+ kssave = installReply(importAlias, inStream);
+ if (kssave) {
+ System.err.println(rb.getString
+ ("Certificate reply was installed in keystore"));
+ } else {
+ System.err.println(rb.getString
+ ("Certificate reply was not installed in keystore"));
+ }
+ } else if (!keyStore.containsAlias(importAlias) ||
+ keyStore.entryInstanceOf(importAlias,
+ KeyStore.TrustedCertificateEntry.class)) {
+ kssave = addTrustedCert(importAlias, inStream);
+ if (kssave) {
+ System.err.println(rb.getString
+ ("Certificate was added to keystore"));
+ } else {
+ System.err.println(rb.getString
+ ("Certificate was not added to keystore"));
+ }
+ }
} else if (command == IMPORTKEYSTORE) {
doImportKeyStore();
kssave = true;