Skip to content

Commit f8ddb57

Browse files
committed
Fix NPE in certificate generator
Signed-off-by: Chris Jackson <[email protected]>
1 parent afcc749 commit f8ddb57

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

bundles/org.opensmarthouse.core.io.jetty.certificate/src/main/java/org/openhab/io/jetty/certificate/internal/CertificateGenerator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,20 @@
6363
/**
6464
*
6565
* @author Kai Kreuzer - Initial contribution
66+
* @author Chris Jackson - Fixed NPE if keystore path not set
6667
*/
6768
public class CertificateGenerator implements BundleActivator {
6869

6970
private static final String JETTY_KEYSTORE_PATH_PROPERTY = "jetty.keystore.path";
70-
private static final String KEYSTORE_PASSWORD = "openhab";
71+
private static final String KEYSTORE_PASSWORD = "opensmarthouse";
7172
private static final String KEYSTORE_ENTRY_ALIAS = "mykey";
7273
private static final String KEYSTORE_JKS_TYPE = "JKS";
7374
private static final String CURVE_NAME = "prime256v1";
7475
private static final String KEY_PAIR_GENERATOR_TYPE = "EC";
7576
private static final String KEY_FACTORY_TYPE = "EC";
7677
private static final String CONTENT_SIGNER_ALGORITHM = "SHA256withECDSA";
7778
private static final String CERTIFICATE_X509_TYPE = "X.509";
78-
private static final String X500_NAME = "CN=openhab.org, OU=None, O=None, L=None, C=None";
79+
private static final String X500_NAME = "CN=opensmarthouse.org, OU=None, O=None, L=None, C=None";
7980

8081
private Logger logger;
8182

@@ -110,6 +111,9 @@ public void stop(BundleContext context) throws Exception {
110111
*/
111112
private KeyStore ensureKeystore() throws KeyStoreException {
112113
String keystorePath = System.getProperty(JETTY_KEYSTORE_PATH_PROPERTY);
114+
if (keystorePath == null) {
115+
throw new KeyStoreException("Failed to create the keystore. Keystore path is not set.");
116+
}
113117
keystoreFile = new File(keystorePath);
114118
KeyStore keyStore = KeyStore.getInstance(KEYSTORE_JKS_TYPE);
115119
if (!keystoreFile.exists()) {

features/karaf/framework/src/main/resources/resources/etc/custom.properties

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
11
# Get rid of annoying Java 11 warning, we know it will be gone!
2-
nashorn.args=--no-deprecation-warning
2+
nashorn.args=--no-deprecation-warning
3+
4+
karaf.name=local
5+
karaf.local.user=opensmarthouse
6+
7+
karaf.systemBundlesStartLevel=50
8+
9+
# custom properties
10+
#java.net.preferIPv4Stack=true
11+
12+
# Lets make a favor to xtext and other eclipse related stuff
13+
karaf.framework=equinox
14+
15+
# Name of file which will collect a bootstrap information and other errors which happens before osgi logging service in
16+
# in place
17+
karaf.bootstrap.log=${karaf.log}/opensmarthouse.log
18+
19+
jetty.keystore.path=${openhab.userdata}/etc/keystore
20+
jetty.truststore.path=${openhab.userdata}/etc/keystore

0 commit comments

Comments
 (0)