NIFI-6178: Implemented capability to add IP SANs to certs

Regenerated test certs for nifi-livy-processors and nifi-standard-processors to fix some broken SSL tests in those modules

This closes #3416.
This commit is contained in:
Jeff Storck 2019-04-03 01:06:04 -04:00 committed by thenatog
parent 4484565df1
commit 25d8f64bed
6 changed files with 6 additions and 2 deletions

View File

@ -49,6 +49,7 @@ import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder;
import org.bouncycastle.util.IPAddress;
import org.bouncycastle.util.io.pem.PemWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -366,7 +367,7 @@ public class TlsHelper {
if (StringUtils.isNotBlank(domainAlternativeNames)) {
for (String alternativeName : domainAlternativeNames.split(",")) {
namesList.add(new GeneralName(GeneralName.dNSName, alternativeName));
namesList.add(new GeneralName(IPAddress.isValid(alternativeName) ? GeneralName.iPAddress : GeneralName.dNSName, alternativeName));
}
}

View File

@ -34,6 +34,7 @@ import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest;
import org.bouncycastle.util.IPAddress;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@ -373,7 +374,9 @@ public class TlsHelperTest {
List<String> extractedSans = extractSanFromCsr(csrWithSan);
assert extractedSans.size() == SAN_COUNT + 1;
List<String> formattedSans = SAN_ENTRIES.stream().map(s -> "DNS: " + s).collect(Collectors.toList());
List<String> formattedSans = SAN_ENTRIES.stream()
.map(s -> (IPAddress.isValid(s) ? "IP Address: " + new GeneralName(GeneralName.iPAddress, s).getName() : "DNS: " + s))
.collect(Collectors.toList());
assert extractedSans.containsAll(formattedSans);
// We check that the SANs also contain the CN