Skip to content

Commit f9a7075

Browse files
committed
bugfix
1 parent e5f6d16 commit f9a7075

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/sys/cert/SysCertManager.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,23 @@ public class SysCertManager extends DSNode {
3737
private DSInfo keystore = getInfo(CERTFILE);
3838
private DSInfo keystorePass = getInfo(CERTFILE_PASS);
3939
private DSInfo keystoreType = getInfo(CERTFILE_TYPE);
40-
private CertCollection localTruststore = (CertCollection) getInfo(LOCAL_TRUSTSTORE).getObject();
41-
private CertCollection quarantine = (CertCollection) getInfo(QUARANTINE).getObject();
40+
private CertCollection localTruststore;
41+
private CertCollection quarantine;
4242

43+
private CertCollection getLocalTruststore() {
44+
if (localTruststore == null) {
45+
localTruststore = (CertCollection) getInfo(LOCAL_TRUSTSTORE).getObject();
46+
}
47+
return localTruststore;
48+
}
49+
50+
private CertCollection getQuarantine() {
51+
if (quarantine == null) {
52+
quarantine = (CertCollection) getInfo(QUARANTINE).getObject();
53+
}
54+
return quarantine;
55+
}
56+
4357
// Methods
4458
// -------
4559

@@ -117,12 +131,12 @@ public void onStarted() {
117131
}
118132

119133
public boolean isInTrustStore(X509Certificate cert) {
120-
return localTruststore.containsCertificate(cert);
134+
return getLocalTruststore().containsCertificate(cert);
121135
}
122136

123137
public void addToQuarantine(X509Certificate cert) {
124138
try {
125-
quarantine.addCertificate(cert);
139+
getQuarantine().addCertificate(cert);
126140
} catch (CertificateEncodingException e) {
127141
error("", e);
128142
}
@@ -132,8 +146,8 @@ public void allow(DSInfo certInfo) {
132146
String name = certInfo.getName();
133147
CertNode certNode = (CertNode) certInfo.getNode();
134148
String certStr = certNode.toElement().toString();
135-
quarantine.remove(certInfo);
136-
localTruststore.addCertificate(name, certStr);
149+
getQuarantine().remove(certInfo);
150+
getLocalTruststore().addCertificate(name, certStr);
137151
}
138152

139153

0 commit comments

Comments
 (0)