Skip to content

OF-3484: Keep generating self-signed certificates for XMPP domain names over 64 characters - #3592

Open
viv wants to merge 1 commit into
igniterealtime:mainfrom
surevine:OF-3484
Open

viv wants to merge 1 commit into
igniterealtime:mainfrom
surevine:OF-3484

Conversation

@viv

@viv viv commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

From Bouncy Castle 1.85, X500NameBuilder.addRDN(BCStyle.CN, String) refuses a common name longer than 64 characters (the RFC 5280 upper bound). Openfire uses its XMPP domain name as the common name of its self-signed certificates, and a domain name can be longer, so after the upgrade in OF-3483 (#3593, which describes the other effects of that upgrade and where Openfire uses Bouncy Castle) such a server would start without a certificate, and updating the issuer details from the Admin Console would fail.

This change adds the common name as an encoded value (a DERUTF8String), which Bouncy Castle does not length-check. The encoding is the same as before, so certificates are unchanged for every domain name. It works on 1.84 as well, so it can be merged before OF-3483.

Alternatives considered:

  • Leaving the common name out fails for the self-signed certificate, whose subject holds only the common name, because 1.85 also refuses an empty issuer.
  • Truncating the common name puts a name in the certificate that is not the domain.
  • Writing the domain as domain components (DC=...) conforms to RFC 5280, but changes the certificate for these servers. It remains the fallback if a later Bouncy Castle also refuses the encoded value; the new tests would show that on the version bump that does it.

New tests generate a self-signed certificate, and update the issuer of one, for a 65-character domain name, and check that the common name is the full domain name. On 1.87 they fail without this change and pass with it.

Where to direct review: whether keeping an over-long common name is acceptable, rather than one of the conforming alternatives. Since OF-3122, Openfire identifies peers by their Subject Alternative Names, not the common name.

From Bouncy Castle 1.85, X500NameBuilder.addRDN(BCStyle.CN, String)
refuses a common name longer than 64 characters, the RFC 5280 upper
bound. Openfire uses its XMPP domain name as the common name of its
self-signed certificates, and a domain name can be longer, so after
the upgrade in OF-3483 such a server would start without a
certificate, and updating the issuer details would fail.

The common name is now added as an encoded value (DERUTF8String),
which Bouncy Castle does not length-check. The encoding is the same
as before, so certificates are unchanged for every domain name.

Leaving the common name out is not an option: a self-signed
certificate's issuer equals its subject, and Bouncy Castle 1.85 also
refuses an empty issuer. If a later release refuses the encoded value
too, writing the domain as domain components is the fallback; the new
tests would fail on that version bump.
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

IdentityStore and CertificateManager now encode certificate common names as DERUTF8String values. New tests check that a 65-character domain is retained in issuer and subject names. The IdentityStore test also checks that the provided organisational unit remains in the issuer and that issuer and subject match.

Suggested reviewers: aberenguel, guusdk

Merge Risk: Minimal · up to c08a4

This change keeps self-signed certificate generation and issuer updates working for XMPP domain names longer than 64 characters. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 3

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the problem: Bouncy Castle 1.85 rejects common names longer than 64 characters, and Openfire uses the XMPP domain as the self-signed certificate common name. It states the fix: …
Full details: Description check

Explanation

The description states the problem: Bouncy Castle 1.85 rejects common names longer than 64 characters, and Openfire uses the XMPP domain as the self-signed certificate common name. It states the fix: encoding the common name as a DERUTF8String. It also names the affected classes' behavior, the tests added, and alternatives considered. It is closely related to the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7081e455-ac5e-4c63-bb2e-139739704d29
Commits

Reviewing files that changed from the base of the PR and between 6f177cd and c08a4ab.

Files selected for processing: 4

  • xmppserver/src/main/java/org/jivesoftware/openfire/keystore/IdentityStore.java
  • xmppserver/src/main/java/org/jivesoftware/util/CertificateManager.java
  • xmppserver/src/test/java/org/jivesoftware/openfire/keystore/IdentityStoreIssuerUpdateTest.java
  • xmppserver/src/test/java/org/jivesoftware/util/CertificateManagerTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@viv
viv requested a review from guusdk December 1, 2026 15:05
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.

1 participant