Repository navigation
Support PEM and Keystore TLS Certificates for JMAP Server - #3240
Draft
prosgarz35 wants to merge 2 commits into
Draft
prosgarz35 wants to merge 2 commits into
prosgarz35 wants to merge 2 commits into
Conversation
chibenwa
reviewed
Oct 6, 2026
| } | ||
|
|
||
| public JMAPConfiguration build() { | ||
| Preconditions.checkState(enabled.isPresent(), "You should specify if JMAP server should be started"); |
Contributor
There was a problem hiding this comment.
Mixing keystore and pem constructs should fail
Enabling TLS without a incomplete keystore or pem should fail
Here
With explicit messages
Contributor
|
Hello @prosgarz35 Would you have time to handle the feedback ? Best regards, Benoit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces support for configuring TLS on the JMAP server directly using
.pemcertificates and private keys, as well as Java Keystores (JKS / PKCS12), matching the existing PEM TLS support found in IMAP, POP3, and SMTP protocols.Prior to this change, JMAP relied on plain HTTP, requiring an external reverse proxy (such as Nginx or Traefik) to terminate TLS. With this enhancement, administrators can terminate TLS natively within Apache James JMAP using standard PEM certificates (e.g. Let's Encrypt certificates) or existing keystores.
Key Changes
server/protocols/jmap(pom.xml):ayza-for-pem(io.github.hakky54:ayza-for-pem) dependency to parse PEM-encoded certificates and private keys (PKCS#1, PKCS#8, EC, RSA) viaPemUtils, consistent with the rest of James.james-server-filesystem-apidependency to resolve certificate/keystore resource locations (file://,classpath://, etc.).JMAPConfiguration.java:tls.keystoreURL/keystoretls.keystoreType/keystoreType(optional, default: JKS)tls.privateKey/privateKeytls.certificates/certificatestls.secret/secret(optional password for keystore or encrypted private key)isTlsEnabled()helper method checking if keystore or PEM certificate/key pair is supplied.@VisibleForTesting).JMAPServer.java:FileSysteminto the Guice constructor.HttpServerwith.secure(...)when TLS is enabled.SslContext:PemUtils.loadCertificate(...)and private key viaPemUtils.loadPrivateKey(...), configured viaSslContextBuilder.forServer(privateKey, certificates).KeyStoreUtils.loadKeyStore(...), configured viaSslContextBuilder.forServer(KeyManagerUtils.createKeyManager(keyStore, password)).RFC 5246andRFC 8446), avoiding insecure older versions (SSLv3, TLS 1.0, TLS 1.1).JMAPModule.java:jmap.properties.Tests:
JMAPConfigurationTestfor verifying TLS properties and builder options.JMAPServerTestverifying successful HTTPS startup and request handling with both PEM certificates/keys and Keystore configurations.Configuration Example (
jmap.properties)Option A: PEM Certificates (e.g., Let's Encrypt)
Option B: Keystore
Adherence to Principles
SslContextBuilder.forServer(PrivateKey, X509Certificate[])without superfluous wrapper layers.ayza-for-pemandFileSystemmechanisms already adopted across James protocols.