BlogJava · Keystore
JavaJKSPKCS#12Spring Boot

JKS vs PKCS#12 — Which Should You Use in 2026?

JKS is a proprietary Java format that Oracle has marked for deprecation. PKCS#12 is the modern, interoperable standard. Here's everything you need to know to make the right choice — and migrate safely.

Navsatech Team·March 2026·7 min read

What is JKS?

JKS (Java KeyStore) is a proprietary binary keystore format created by Sun Microsystems and shipped with Java since JDK 1.1. It stores private keys, certificates, and trusted CA certificates in a single file protected by a password.

For decades it was the default format for Java SSL/TLS configuration — used in Tomcat, JBoss, WebLogic, and countless enterprise applications. If you've ever run keytool -genkeypair without specifying a format, you got a JKS file.

What is PKCS#12?

PKCS#12 (also called PFX) is an industry-standard format defined by RSA and later standardised as RFC 7292. Unlike JKS, it is not tied to Java — it works with OpenSSL, Windows, macOS Keychain, browsers, and every major TLS implementation.

A .p12 or .pfx file can store private keys, certificates, and the full certificate chain in a single portable bundle.

Side-by-side comparison

FeatureJKSPKCS#12
StandardProprietary (Sun/Oracle)RFC 7292 (industry standard)
Cross-platformJava onlyOpenSSL, Windows, macOS, Java
Default in JavaJDK 1.1 – JDK 8JDK 9+ (as of JEP 229)
File extension.jks.p12 / .pfx
Chain storageManual, error-proneBuilt-in, ordered
Deprecation statusDeprecated (JDK 17+)Recommended
Tool supportkeytool onlykeytool + openssl + all others
Password protectionKeystore + key passwordsSingle store password

JKS deprecation — what it actually means

Starting with JDK 9 (JEP 229), Oracle changed the default keystore type from JKS to PKCS12. From JDK 17 onwards, using JKS generates a deprecation warning:

JDK 17+ warning
WARNING: The JKS keystore uses a proprietary format. It is recommended to migrate
to PKCS12 which is an industry standard format using:
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12
-deststoretype pkcs12

JKS is not removed — it still works. But Oracle is signalling clearly that PKCS12 is the future, and future JDK versions may drop JKS support entirely.

When should you migrate?

Migrate now if you're on JDK 11+
PKCS12 is the default, the tooling is better, and you'll avoid deprecation warnings in your build output.
Migrate if your cert is also used outside Java
If Nginx, a load balancer, or any non-Java system also needs the certificate, PKCS12 works everywhere without conversion.
Migrate if you're setting up a new service
No reason to start with a deprecated format. Generate PKCS12 from the start.
Wait if your app is on JDK 8 and heavily tested
If you're running a stable JDK 8 environment and have no issues, migration introduces risk with no immediate benefit. Test thoroughly before migrating.

How to migrate JKS → PKCS#12

Option 1 — keytool (simplest, built into Java)

keytool -importkeystore \
  -srckeystore keystore.jks \
  -srcstoretype JKS \
  -srcstorepass your-jks-password \
  -destkeystore keystore.p12 \
  -deststoretype PKCS12 \
  -deststorepass your-p12-password \
  -noprompt

Option 2 — OpenSSL (for more control)

# First export the private key and cert from JKS
keytool -importkeystore -srckeystore keystore.jks \
  -destkeystore temp.p12 -deststoretype PKCS12

# Then rebuild with OpenSSL to include full chain
openssl pkcs12 -in temp.p12 -out key.pem -nocerts -nodes
openssl pkcs12 -in temp.p12 -out cert.pem -nokeys

openssl pkcs12 -export \
  -in cert.pem -inkey key.pem \
  -certfile intermediate.pem \
  -out final.p12 -name "my-cert"

Verify the migration worked

keytool -list -v -keystore keystore.p12 -storetype PKCS12 -storepass your-p12-password

Configuring Spring Boot with PKCS#12

Update your application.properties or application.yml:

# application.properties
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-type=PKCS12
server.ssl.key-store-password=your-password
server.ssl.key-alias=my-cert
# application.yml
server:
  ssl:
    key-store: classpath:keystore.p12
    key-store-type: PKCS12
    key-store-password: your-password
    key-alias: my-cert

Inspect both formats instantly

Not sure what's in your keystore?
Upload your JKS or PKCS#12 file to CertLens. Get a visual breakdown of every alias, certificate chain, expiry date, and risk level — without running a single keytool command.
Inspect Your Keystore →
✓ JKS & PKCS#12 supported
✓ Visual chain per alias
✓ Expiry & risk assessment
✓ Files never stored
Copilot
CertLens Copilot
AI-powered PKI assistant
Hi! I'm CertLens Copilot — ask me anything about certificates, TLS errors, JKS keystores, SWIFT PKI, or trust chain issues.