Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ private void loadCertSigner() {

String certSignerFactoryClass = System.getProperty(ZTSConsts.ZTS_PROP_CERT_SIGNER_FACTORY_CLASS,
ZTSConsts.ZTS_CERT_SIGNER_FACTORY_CLASS);
if (StringUtil.isEmpty(certSignerFactoryClass)) {
LOGGER.error("No CertSignerFactory class configured");
certSigner = null;
return;
}
try {
CertSignerFactory certSignerFactory = (CertSignerFactory) Class.forName(certSignerFactoryClass)
.getDeclaredConstructor().newInstance();
Expand Down Expand Up @@ -754,6 +759,11 @@ public boolean insertX509CertRecord(X509CertRecord certRecord) {
public String generateX509Certificate(final String provider, final String certIssuer, final String csr,
final String keyUsage, int expiryTime, Priority priority, final String keySignerId) {

if (certSigner == null) {
LOGGER.error("CertSigner is not available");
return null;
}

String pemCert = null;
try {
pemCert = certSigner.generateX509Certificate(provider, certIssuer, csr, keyUsage,
Expand All @@ -768,6 +778,12 @@ public String generateX509Certificate(final String provider, final String certIs
}

public String getCACertificate(final String provider, final String signerKeyId) {

if (certSigner == null) {
LOGGER.error("CertSigner is not available");
return null;
}

try {
return certSigner.getCACertificate(provider, signerKeyId);
} catch (ServerResourceException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2505,4 +2505,17 @@ public void testParseTimeUnit() {
assertEquals(InstanceCertManager.parseTimeUnit("invalidstring"), TimeUnit.DAYS);
}

@Test
public void testEmptyCertSignerFactoryClassName() {

System.setProperty(ZTSConsts.ZTS_PROP_CERT_SIGNER_FACTORY_CLASS, "");

InstanceCertManager instanceManager = new InstanceCertManager(null, null, null, new DynamicConfigBoolean(false));
assertNull(instanceManager.generateX509Certificate("provider", "issuer", "csr", "client", 0, Priority.High, "keyId"));
assertNull(instanceManager.getCACertificate("provider", "keyId"));

instanceManager.shutdown();

System.clearProperty(ZTSConsts.ZTS_PROP_CERT_SIGNER_FACTORY_CLASS);
}
}