You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by fa...@apache.org on 2024/01/20 17:17:32 UTC

(incubator-pekko) branch main updated: improve performance in PEM reader (#997)

This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f142e3e18 improve performance in PEM reader (#997)
8f142e3e18 is described below

commit 8f142e3e1890ed63d63a8ad56bbe9e061fa4ff13
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sat Jan 20 18:17:26 2024 +0100

    improve performance in PEM reader (#997)
    
    * improve performance in PEM reader
    
    * revert use of java 11 readString method
---
 .../remote/artery/tcp/ssl/PemManagersProvider.scala  | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/PemManagersProvider.scala b/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/PemManagersProvider.scala
index cd7306afcb..21b26105ba 100644
--- a/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/PemManagersProvider.scala
+++ b/remote/src/main/scala/org/apache/pekko/remote/artery/tcp/ssl/PemManagersProvider.scala
@@ -13,24 +13,17 @@
 
 package org.apache.pekko.remote.artery.tcp.ssl
 
-import java.io.ByteArrayInputStream
 import java.io.File
 import java.nio.charset.StandardCharsets
 import java.nio.file.Files
-import java.security.KeyStore
-import java.security.PrivateKey
-import java.security.cert.Certificate
-import java.security.cert.CertificateFactory
-import java.security.cert.X509Certificate
+import java.security.{ KeyStore, PrivateKey }
+import java.security.cert.{ Certificate, CertificateFactory, X509Certificate }
 
 import org.apache.pekko
 import pekko.annotation.InternalApi
-import pekko.pki.pem.DERPrivateKeyLoader
-import pekko.pki.pem.PEMDecoder
-import javax.net.ssl.KeyManager
-import javax.net.ssl.KeyManagerFactory
-import javax.net.ssl.TrustManager
-import javax.net.ssl.TrustManagerFactory
+import pekko.pki.pem.{ DERPrivateKeyLoader, PEMDecoder }
+
+import javax.net.ssl.{ KeyManager, KeyManagerFactory, TrustManager, TrustManagerFactory }
 
 import scala.concurrent.blocking
 
@@ -94,8 +87,7 @@ private[ssl] object PemManagersProvider {
    */
   @InternalApi
   private[ssl] def loadCertificate(filename: String): Certificate = blocking {
-    val bytes = Files.readAllBytes(new File(filename).toPath)
-    certFactory.generateCertificate(new ByteArrayInputStream(bytes))
+    certFactory.generateCertificate(Files.newInputStream(new File(filename).toPath))
   }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org