Skip to content

Fix API SSL startup#321

Merged
crowetic merged 3 commits intomasterfrom
bugfix/api-ssl-startup
Mar 4, 2026
Merged

Fix API SSL startup#321
crowetic merged 3 commits intomasterfrom
bugfix/api-ssl-startup

Conversation

@Philreact
Copy link
Copy Markdown

  1. SslUtils – hostname resolution (server cert SAN)
    Wrapped InetAddress.getLocalHost() and hostname/canonical usage in a try/catch.
    On any exception, log a warning and continue with a minimal SAN list: localhost, 127.0.0.1, and IPs from network interface enumeration (unchanged).
    Ensures server cert generation always completes on Pi/Mac and similar setups; SAN still includes loopback and LAN IPs.

  2. ApiService – corrupt keystore handling
    When the keystore file exists and is readable, attempt to load it (with the default PKCS12 provider) before starting Jetty.
    If load fails (e.g. EOFException, corrupt format), log a warning, delete the bad file, call SslUtils.generateSsl(), then continue startup.
    Users no longer need to manually delete a corrupt keystore; the next startup recovers automatically.

  3. SslUtils.createKeystore() – write with default PKCS12 provider
    Replaced KeyStore.getInstance("PKCS12", "BC") with KeyStore.getInstance("PKCS12") for the keystore used in createKeystore() (the one we write and store()).
    Keystore file is still standard PKCS12 (one key entry with cert chain).
    Avoids “JCE cannot authenticate the provider BC” during keyStore.store() on Oracle Java SE; cert/key generation in SslUtils still uses BC.

  4. ApiService – load keystore with default provider
    Removed sslContextFactory.setKeyStoreProvider("BC") so Jetty loads the keystore with the default (e.g. SunJSSE) PKCS12 implementation.
    Pre-start validation of the keystore now also uses KeyStore.getInstance("PKCS12") (default provider) so validation matches Jetty and does not falsely treat a valid keystore as corrupt on JVMs where BC cannot load PKCS12.

@Philreact Philreact assigned IceBurst and unassigned IceBurst Feb 28, 2026
@Philreact Philreact requested a review from IceBurst February 28, 2026 23:34
@crowetic crowetic merged commit 41859ba into master Mar 4, 2026
@nbenaglia nbenaglia deleted the bugfix/api-ssl-startup branch March 15, 2026 07:56
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.

4 participants