You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "rajinisivaram (via GitHub)" <gi...@apache.org> on 2023/09/25 11:14:30 UTC
[GitHub] [kafka] rajinisivaram commented on a diff in pull request #14440: [KAFKA-15117] In TestSslUtils set SubjectAlternativeNames to null if there are no hostnames
rajinisivaram commented on code in PR #14440:
URL: https://github.com/apache/kafka/pull/14440#discussion_r1335740613
##########
clients/src/test/java/org/apache/kafka/test/TestSslUtils.java:
##########
@@ -399,10 +399,12 @@ public CertificateBuilder(int days, String algorithm) {
}
public CertificateBuilder sanDnsNames(String... hostNames) throws IOException {
- GeneralName[] altNames = new GeneralName[hostNames.length];
- for (int i = 0; i < hostNames.length; i++)
- altNames[i] = new GeneralName(GeneralName.dNSName, hostNames[i]);
- subjectAltName = GeneralNames.getInstance(new DERSequence(altNames)).getEncoded();
+ if (hostNames.length > 0) {
+ GeneralName[] altNames = new GeneralName[hostNames.length];
+ for (int i = 0; i < hostNames.length; i++)
+ altNames[i] = new GeneralName(GeneralName.dNSName, hostNames[i]);
+ subjectAltName = GeneralNames.getInstance(new DERSequence(altNames)).getEncoded();
+ }
Review Comment:
Should we also add an `else` clause that sets `subjectAltName = null` to preserve the override semantics if the method is called twice? Just in case some test relies on overriding existing hostname in future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org