This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 7716ebb4bf Simplify code. Based on PR #651 by wonyongChoi05 7716ebb4bf is described below commit 7716ebb4bf1165fb6b6f46980160f17f1eaba941 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Sep 5 11:22:49 2023 +0100 Simplify code. Based on PR #651 by wonyongChoi05 --- java/org/apache/coyote/ajp/AjpProcessor.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java b/java/org/apache/coyote/ajp/AjpProcessor.java index 0910855da6..8b8ae93cc7 100644 --- a/java/org/apache/coyote/ajp/AjpProcessor.java +++ b/java/org/apache/coyote/ajp/AjpProcessor.java @@ -26,8 +26,10 @@ import java.security.NoSuchProviderException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.regex.Pattern; @@ -1122,10 +1124,10 @@ public class AjpProcessor extends AbstractProcessor { @Override protected final void populateSslRequestAttributes() { if (!certificates.isNull()) { + List<X509Certificate> jsseCerts = new ArrayList<>(); ByteChunk certData = certificates.getByteChunk(); - X509Certificate jsseCerts[] = null; - ByteArrayInputStream bais = new ByteArrayInputStream(certData.getBytes(), certData.getStart(), - certData.getLength()); + ByteArrayInputStream bais = + new ByteArrayInputStream(certData.getBytes(), certData.getStart(), certData.getLength()); // Fill the elements. try { CertificateFactory cf; @@ -1137,21 +1139,13 @@ public class AjpProcessor extends AbstractProcessor { } while (bais.available() > 0) { X509Certificate cert = (X509Certificate) cf.generateCertificate(bais); - if (jsseCerts == null) { - jsseCerts = new X509Certificate[1]; - jsseCerts[0] = cert; - } else { - X509Certificate[] temp = new X509Certificate[jsseCerts.length + 1]; - System.arraycopy(jsseCerts, 0, temp, 0, jsseCerts.length); - temp[jsseCerts.length] = cert; - jsseCerts = temp; - } + jsseCerts.add(cert); } } catch (CertificateException | NoSuchProviderException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; } - request.setAttribute(SSLSupport.CERTIFICATE_KEY, jsseCerts); + request.setAttribute(SSLSupport.CERTIFICATE_KEY, jsseCerts.toArray(new X509Certificate[0])); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org