Skip to content

Add mTLS examples ported from akka-grpc PR #1781#691

Open
pjfanning wants to merge 7 commits intoapache:mainfrom
pjfanning:copilot/copy-pull-1781-switch-to-pekko
Open

Add mTLS examples ported from akka-grpc PR #1781#691
pjfanning wants to merge 7 commits intoapache:mainfrom
pjfanning:copilot/copy-pull-1781-switch-to-pekko

Conversation

@pjfanning
Copy link
Copy Markdown
Member

The changes in https://github.com/akka/akka-grpc/releases/tag/v2.3.2 are now available under the Apache license.

Ports the mTLS (mutual TLS) support from akka-grpc#1781, replacing all akka references with pekko. Uses pekko-pki's DERPrivateKeyLoader/PEMDecoder.

New files

  • docs/src/main/paradox/mtls.md — mTLS documentation; wired into index
  • plugin-tester-java/MtlsGreeterServer.java, MtlsGreeterClient.java, cert files under src/main/resources/certs/
  • plugin-tester-scala/MtlsGreeterServer.scala, MtlsGreeterClient.scala, MtlsIntegrationSpec.scala, cert files, logback.xml

Build changes

  • build.sbt: adds pekko-pki to both plugin testers; adds pekko-actor-testkit-typed (test) to Scala tester
  • project/Dependencies.scala: adds Runtime.logback to pluginTester
  • plugin-tester-java/application.conf: adds pekko.http.server.enable-http2 = on

SSL context construction (both Java and Scala)

Server loads its own keypair and trusts any client cert signed by the configured CA:

val serverPrivateKey = DERPrivateKeyLoader.load(PEMDecoder.decode(classPathFileAsString("certs/localhost-server.key")))
keyStore.setKeyEntry("private", serverPrivateKey, new Array[Char](0), Array[Certificate](serverCert))
// ...
engine.setNeedClientAuth(true)

Client presents its keypair and trusts the server cert via the same CA:

val clientPrivateKey = DERPrivateKeyLoader.load(PEMDecoder.decode(classPathFileAsString("certs/client1.key")))
val clientSettings = GrpcClientSettings.connectToServiceAt("localhost", 8443).withSslContext(sslContext())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants