summaryrefslogtreecommitdiff
path: root/csharp/test/IceSSL/certs/makecerts.py
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/test/IceSSL/certs/makecerts.py')
-rwxr-xr-xcsharp/test/IceSSL/certs/makecerts.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/csharp/test/IceSSL/certs/makecerts.py b/csharp/test/IceSSL/certs/makecerts.py
new file mode 100755
index 00000000000..839a2442ab6
--- /dev/null
+++ b/csharp/test/IceSSL/certs/makecerts.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import os, sys, shutil
+
+for toplevel in [".", "..", "../..", "../../..", "../../../..", "../../../../.."]:
+ toplevel = os.path.normpath(toplevel)
+ if os.path.exists(os.path.join(toplevel, "scripts", "TestUtil.py")):
+ break
+else:
+ raise RuntimeError("can't find toplevel directory!")
+
+sys.path.append(toplevel)
+from scripts import *
+
+#
+# Show usage information.
+#
+def usage():
+ print("Usage: " + sys.argv[0] + " [options]")
+ print("")
+ print("Options:")
+ print("-h Show this message.")
+ print("-f Force an update to the C# files.")
+
+#
+# Check arguments
+#
+force = 0
+for x in sys.argv[1:]:
+ if x == "-h":
+ usage()
+ sys.exit(0)
+ elif x == "-f":
+ force = 1
+ elif x.startswith("-"):
+ print(sys.argv[0] + ": unknown option `" + x + "'")
+ print("")
+ usage()
+ sys.exit(1)
+ else:
+ usage()
+ sys.exit(1)
+
+cppcerts = os.path.join(TestUtil.getIceDir("cpp"), "test", "IceSSL", "certs")
+
+for x in ("cacert1.pem", "cacert2.pem"):
+ if force or not os.path.exists(x):
+ shutil.copyfile(os.path.join(cppcerts, x), x)
+
+certs = [\
+ "c_rsa_nopass_ca1_exp", \
+ "c_rsa_nopass_ca1", \
+ "c_rsa_nopass_ca2", \
+ "s_rsa_nopass_ca1_exp", \
+ "s_rsa_nopass_ca1", \
+ "s_rsa_nopass_ca2", \
+ "s_rsa_nopass_ca1_cn1", \
+ "s_rsa_nopass_ca1_cn2", \
+]
+
+for x in certs:
+ if force or not os.path.exists(x + ".pfx"):
+ cert = os.path.join(cppcerts, x)
+ os.system("openssl pkcs12 -in " + cert + "_pub.pem -inkey " + cert + "_priv.pem -export -out " + x + \
+ ".pfx -passout pass:password")
+ print("Created " + x + ".pfx")
+
+if force or not os.path.exists("cacert2.pfx"):
+ cert = os.path.join(cppcerts, "cacert2.pem")
+ key = os.path.join(cppcerts, "cakey2.pem")
+ os.system("openssl pkcs12 -in " + cert + " -inkey " + key + " -export -out cacert2.pfx -passout pass:password")
+#
+# Done.
+#
+print("Done.")