summaryrefslogtreecommitdiff
path: root/java/certs
diff options
context:
space:
mode:
Diffstat (limited to 'java/certs')
-rw-r--r--java/certs/ImportKey.java112
-rwxr-xr-xjava/certs/makecerts.py12
2 files changed, 62 insertions, 62 deletions
diff --git a/java/certs/ImportKey.java b/java/certs/ImportKey.java
index dbdfbb8c9e5..8edb473e87d 100644
--- a/java/certs/ImportKey.java
+++ b/java/certs/ImportKey.java
@@ -14,68 +14,68 @@ public class ImportKey
public static void
main(String[] args)
{
- if(args.length != 5)
- {
- //
- // Arguments:
- //
- // pkcs12-file A file in PKCS12 format that contains the
- // private key and certificate chain.
- //
- // alias The key's friendly name in pkcs12-file and the
- // alias for the key in the new keystore.
- //
- // cert-file The CA certificate file in DER format.
- //
- // keystore-file The name of the keystore file to update or
- // create.
- //
- // password The password to use for the key and keystore.
- //
- System.err.println("Usage: ImportKey pkcs12-file alias cert-file " +
- "keystore-file password");
- System.exit(1);
- }
+ if(args.length != 5)
+ {
+ //
+ // Arguments:
+ //
+ // pkcs12-file A file in PKCS12 format that contains the
+ // private key and certificate chain.
+ //
+ // alias The key's friendly name in pkcs12-file and the
+ // alias for the key in the new keystore.
+ //
+ // cert-file The CA certificate file in DER format.
+ //
+ // keystore-file The name of the keystore file to update or
+ // create.
+ //
+ // password The password to use for the key and keystore.
+ //
+ System.err.println("Usage: ImportKey pkcs12-file alias cert-file " +
+ "keystore-file password");
+ System.exit(1);
+ }
- final String pkcs12File = args[0];
- final String alias = args[1];
- final String certFile = args[2];
- final String keystoreFile = args[3];
- final char[] password = args[4].toCharArray();
+ final String pkcs12File = args[0];
+ final String alias = args[1];
+ final String certFile = args[2];
+ final String keystoreFile = args[3];
+ final char[] password = args[4].toCharArray();
- try
- {
- KeyStore src = KeyStore.getInstance("PKCS12");
- src.load(new java.io.FileInputStream(pkcs12File), password);
+ try
+ {
+ KeyStore src = KeyStore.getInstance("PKCS12");
+ src.load(new java.io.FileInputStream(pkcs12File), password);
- KeyStore dest = KeyStore.getInstance("JKS");
- java.io.File f = new java.io.File(keystoreFile);
- if(f.exists())
- {
- dest.load(new java.io.FileInputStream(f), password);
- }
- else
- {
- dest.load(null, null);
- }
- Certificate[] chain = src.getCertificateChain(alias);
- Key key = src.getKey(alias, password);
+ KeyStore dest = KeyStore.getInstance("JKS");
+ java.io.File f = new java.io.File(keystoreFile);
+ if(f.exists())
+ {
+ dest.load(new java.io.FileInputStream(f), password);
+ }
+ else
+ {
+ dest.load(null, null);
+ }
+ Certificate[] chain = src.getCertificateChain(alias);
+ Key key = src.getKey(alias, password);
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate)
- cf.generateCertificate(new java.io.FileInputStream(certFile));
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate)
+ cf.generateCertificate(new java.io.FileInputStream(certFile));
- dest.setKeyEntry(alias, key, password, chain);
- dest.setCertificateEntry("cacert", cert);
+ dest.setKeyEntry(alias, key, password, chain);
+ dest.setCertificateEntry("cacert", cert);
- dest.store(new java.io.FileOutputStream(keystoreFile), password);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- System.exit(1);
- }
+ dest.store(new java.io.FileOutputStream(keystoreFile), password);
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ System.exit(1);
+ }
- System.exit(0);
+ System.exit(0);
}
}
diff --git a/java/certs/makecerts.py b/java/certs/makecerts.py
index 08429db1b1e..46e278f205a 100755
--- a/java/certs/makecerts.py
+++ b/java/certs/makecerts.py
@@ -50,18 +50,18 @@ if not os.environ.has_key("ICE_HOME"):
target = "client.jks"
if force or not os.path.exists(target):
if os.path.exists(target):
- os.remove(target)
+ os.remove(target)
os.system("openssl pkcs12 -in c_rsa1024_pub.pem -inkey c_rsa1024_priv.pem -export -out client.p12" \
- " -name rsakey -passout pass:password -certfile cacert.pem")
+ " -name rsakey -passout pass:password -certfile cacert.pem")
os.system("java -classpath . ImportKey client.p12 rsakey cacert.pem " + target + " password")
os.remove("client.p12")
print "Created " + target
target = "server.jks"
if force or not os.path.exists(target):
if os.path.exists(target):
- os.remove(target)
+ os.remove(target)
os.system("openssl pkcs12 -in s_rsa1024_pub.pem -inkey s_rsa1024_priv.pem -export -out server.p12" \
- " -name rsakey -passout pass:password -certfile cacert.pem")
+ " -name rsakey -passout pass:password -certfile cacert.pem")
os.system("java -classpath . ImportKey server.p12 rsakey cacert.pem " + target + " password")
os.remove("server.p12")
print "Created " + target
@@ -72,10 +72,10 @@ if force or not os.path.exists(target):
ts = "certs.jks"
if force or not os.path.exists(ts):
if os.path.exists(ts):
- os.remove(ts)
+ os.remove(ts)
os.system("openssl x509 -in cacert.pem -outform DER -out cacert.der")
os.system("keytool -import -alias cacert -file cacert.der -keystore " + ts + \
- " -storepass password -noprompt")
+ " -storepass password -noprompt")
os.remove("cacert.der")
print "Created " + ts