-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b634977
commit f6160f9
Showing
7 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFmDCCA4CgAwIBAgIQU9C87nMpOIFKYpfvOHFHFDANBgkqhkiG9w0BAQsFADBm | ||
MQswCQYDVQQGEwJVUzEzMDEGA1UEChMqKFNUQUdJTkcpIEludGVybmV0IFNlY3Vy | ||
aXR5IFJlc2VhcmNoIEdyb3VwMSIwIAYDVQQDExkoU1RBR0lORykgUHJldGVuZCBQ | ||
ZWFyIFgxMB4XDTE1MDYwNDExMDQzOFoXDTM1MDYwNDExMDQzOFowZjELMAkGA1UE | ||
BhMCVVMxMzAxBgNVBAoTKihTVEFHSU5HKSBJbnRlcm5ldCBTZWN1cml0eSBSZXNl | ||
YXJjaCBHcm91cDEiMCAGA1UEAxMZKFNUQUdJTkcpIFByZXRlbmQgUGVhciBYMTCC | ||
AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALbagEdDTa1QgGBWSYkyMhsc | ||
ZXENOBaVRTMX1hceJENgsL0Ma49D3MilI4KS38mtkmdF6cPWnL++fgehT0FbRHZg | ||
jOEr8UAN4jH6omjrbTD++VZneTsMVaGamQmDdFl5g1gYaigkkmx8OiCO68a4QXg4 | ||
wSyn6iDipKP8utsE+x1E28SA75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QJHo7kGcViT7sETn6Jz9KOhvYcXkJ7po6d93A/jy4GKPIPnsKKNEmR | ||
xUuXY4xRdh45tMJnLTUDdC9FIU0flTeO9/vNpVA8OPU1i14vCz+MU8KX1bV3GXm/ | ||
fxlB7VBBjX9v5oUep0o/j68R/iDlCOM4VVfRa8gX6T2FU7fNdatvGro7uQzIvWof | ||
gN9WUwCbEMBy/YhBSrXycKA8crgGg3x1mIsopn88JKwmMBa68oS7EHM9w7C4y71M | ||
7DiA+/9Qdp9RBWJpTS9i/mDnJg1xvo8Xz49mrrgfmcAXTCJqXi24NatI3Oc= | ||
-----END CERTIFICATE----- |
57 changes: 57 additions & 0 deletions
57
zbctl-java/src/main/java/io/camunda/zbctl/KeystoreManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.camunda.zbctl; | ||
|
||
import java.io.*; | ||
import java.security.KeyStore; | ||
import java.security.KeyStoreException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.cert.Certificate; | ||
import java.security.cert.CertificateException; | ||
import java.security.cert.CertificateFactory; | ||
|
||
public class KeystoreManager { | ||
|
||
private static InputStream fullStream(String fname) throws IOException { | ||
FileInputStream fis = new FileInputStream(fname); | ||
DataInputStream dis = new DataInputStream(fis); | ||
byte[] bytes = new byte[dis.available()]; | ||
dis.readFully(bytes); | ||
return new ByteArrayInputStream(bytes); | ||
} | ||
|
||
public void createKeystore( | ||
String keystoreFileName, String keystorePassword, String certAlias, String certPath) | ||
throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException { | ||
|
||
char[] password = keystorePassword.toCharArray(); | ||
|
||
// Create Keystore if it doesn't exist | ||
File keystoreFile = new File(keystoreFileName); | ||
if (keystoreFile.exists()) { | ||
keystoreFile.delete(); | ||
} | ||
|
||
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); | ||
keystore.load(null, password); | ||
|
||
FileOutputStream fos = new FileOutputStream(keystoreFileName); | ||
keystore.store(fos, password); | ||
fos.close(); | ||
|
||
// Create Certificate | ||
CertificateFactory cf = CertificateFactory.getInstance("X.509"); | ||
InputStream certstream = fullStream(certPath); | ||
Certificate certs = cf.generateCertificate(certstream); | ||
|
||
// Add the certificate | ||
keystore.setCertificateEntry(certAlias, certs); | ||
|
||
// Update the keystore contents | ||
FileOutputStream out = new FileOutputStream(keystoreFile); | ||
keystore.store(out, password); | ||
out.close(); | ||
|
||
// Configure the jvm to use the keystore | ||
System.setProperty("javax.net.ssl.trustStore", keystoreFileName); | ||
System.setProperty("javax.net.ssl.trustStorePassword", keystorePassword); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.