Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use keytool to create, inspect, convert, and secure Java keystores and truststores. For new deployments on JDK 9 and later, choose PKCS12 unless an older application specifically requires JKS. The dependable workflow is to generate a key pair, submit a certificate-signing request (CSR), verify the returned certificate fingerprints, import the CA chain under the original alias, and then inspect the resulting entries and chain.

What keytool manages

keytool is the Java Development Kit (JDK) command-line utility for key and certificate management. It stores private keys, public certificates, certificate chains, and trusted certificates in a keystore. The utility can generate key pairs, create PKCS #10 certificate-signing requests, import certificate replies or trust anchors, export certificates, list aliases, print certificate details, copy entries between keystores, and change passwords.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A keystore is a file containing cryptographic entries; it is not automatically a truststore. A server identity keystore normally contains a private-key entry and its certificate chain. A truststore normally contains trusted-certificate entries, such as the root or intermediate certificates that a TLS client is allowed to trust. One file can technically contain both types, but separating identity and trust material makes administration and troubleshooting clearer.

Choose JKS or PKCS12 before creating the file

JDK 9 and later use PKCS12 as the default keystore implementation. PKCS12 is based on the RSA PKCS #12 Personal Information Exchange Syntax Standard and is designed to store or transport private keys, certificates, and other secrets. JKS is Oracle’s proprietary keystore format. Both remain supported by modern JDKs, but they are not interchangeable unless the store type is identified correctly.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Decision point PKCS12 JKS
Default status Default keystore type in JDK 9 and later. Not the default in JDK 9 and later, although still supported.
Interoperability Standardized format with broad support outside Java. Oracle-specific format; support is strongest in Java tooling.
Private keys and chains Supports private keys, certificates, and certificate chains. Supports private keys, certificates, and certificate chains.
Password and integrity behavior Uses the PKCS #12 protection and integrity mechanisms implemented by the JDK. Uses JKS’s proprietary protection and integrity implementation.
Legacy compatibility Preferred for new JDK 9+ applications, but verify that old consumers accept it. Use when an established application, vendor process, or deployment script explicitly requires JKS.
Migration effort Usually a direct -importkeystore conversion from JKS. Usually a direct conversion from PKCS12 when legacy compatibility is necessary.

Specify -storetype explicitly whenever a file crosses application or JDK boundaries. Explicit commands prevent a file from being opened with an unintended default and make deployment documentation reproducible.

Prepare the keystore workflow

  • Record the JDK version that will run the application. Defaults and algorithm support can differ between JDK releases.
  • Choose a stable alias, such as app-server. The alias identifies the entry throughout CSR creation, certificate import, renewal, and troubleshooting.
  • Decide whether the file is an identity keystore, a truststore, or a deliberately combined store.
  • Choose a protected path and restrictive operating-system file permissions. Anyone who can read a private-key keystore may be able to impersonate the service.
  • Know the certificate subject and the DNS names that the certificate authority will place in the Subject Alternative Name extension. A correct trust chain does not repair a hostname mismatch.
  • Have an independent, trusted way to obtain the CA certificate fingerprints before importing them as trusted.

Create a new keystore and key pair

-genkeypair creates a public/private key pair and a self-signed certificate in one operation. The self-signed certificate is a temporary placeholder; it will be replaced by a CA-signed certificate after the CSR is approved.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Run the command below, changing the alias, distinguished name, path, algorithm, and validity to match the service. The command intentionally omits passwords so keytool can prompt for them.
keytool -genkeypair 
  -alias app-server 
  -keyalg RSA 
  -keysize 2048 
  -validity 365 
  -dname "CN=app.example.com, OU=Platform, O=Example, L=London, ST=London, C=GB" 
  -keystore app.p12 
  -storetype PKCS12
  • -alias names the private-key entry.
  • -keyalg RSA and -keysize 2048 select the key algorithm and size shown in this example; use the policy required by your CA and organization.
  • -validity 365 sets the lifetime of the initial self-signed certificate. The issued certificate’s lifetime is controlled by the CA.
  • -dname sets the distinguished name. Modern certificate validation generally depends heavily on Subject Alternative Names, so provide the names required by the CA’s enrollment process as well.
  • -keystore supplies the file path, while -storetype PKCS12 makes the format unambiguous.

When prompted, set a store password and a private-key password. On many current JDKs, pressing Enter at the key-password prompt can use the store password, but record what the resulting application configuration actually expects rather than relying on that behavior implicitly.

Create a CSR and obtain the signed certificate

After generating the key pair, create a CSR. The CSR contains the public key and requested subject information, but never the private key.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
keytool -certreq 
  -alias app-server 
  -file app-server.csr 
  -keystore app.p12 
  -storetype PKCS12

Submit app-server.csr through the CA’s enrollment process. Keep the original keystore and alias unchanged while the request is pending. The CA may return a leaf certificate, one or more intermediate certificates, and instructions for obtaining a root certificate. Preserve the chain order and file formats supplied by the CA.

Before importing any certificate as trusted, inspect it and compare its fingerprint with a value obtained through an independent trusted channel:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
keytool -printcert -file intermediate-ca.pem

Oracle’s keytool specification states: “Only when the fingerprints are equal is it assured that the certificate wasn’t replaced in transit with somebody else’s certificate.” A fingerprint copied from the same untrusted download location does not provide independent verification.

Import a CA certificate or the issued chain

Import a CA certificate into a truststore

For a client truststore, import the CA certificate that should be trusted. Use a distinct alias that identifies the authority and role.

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
keytool -importcert 
  -alias example-intermediate-ca 
  -file intermediate-ca.pem 
  -keystore truststore.p12 
  -storetype PKCS12

Review the certificate details and fingerprint at the confirmation prompt. Import a root or intermediate only after its identity has been verified. Importing an arbitrary certificate as a trusted entry bypasses the normal chain-of-trust decision for that certificate.

Import the CA reply into the identity keystore

When the CA returns the certificate corresponding to your CSR, import it using the same alias that holds the private key:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
keytool -importcert 
  -alias app-server 
  -file app-server-chain.pem 
  -keystore app.p12 
  -storetype PKCS12

keytool matches the CA reply to the existing private key through the alias and the public key. If the alias is wrong, or the returned certificate does not correspond to the private key, the import fails instead of producing a usable identity entry. If the CA gave you separate files, import the required CA certificates first under their own aliases, then import the leaf certificate reply under app-server, following the CA’s documented chain order.

Inspect aliases, entry types, and fingerprints

List the entire store in verbose mode before assigning it to an application:

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
keytool -list -v 
  -keystore app.p12 
  -storetype PKCS12

Check the following fields:

  • Alias: confirms that the expected name exists and has the spelling used by application configuration.
  • Entry type: PrivateKeyEntry indicates an identity entry; trustedCertEntry indicates a certificate trusted on its own.
  • Certificate chain length: a server identity normally needs its leaf certificate plus the intermediates required by clients. A missing intermediate is a common cause of handshake failures.
  • Owner and issuer: confirm that the leaf is issued by the expected CA and that each issuer matches the subject of the next certificate in the chain.
  • Validity dates: check that neither the leaf nor an intermediate is expired or not-yet-valid.
  • SHA-256 fingerprint: compare it with the value supplied by the CA or another trusted administrator.
  • Public-key algorithm and key size: confirm that they meet the runtime and CA policy.

To inspect one alias without scrolling through unrelated entries:

keytool -list -v 
  -alias app-server 
  -keystore app.p12 
  -storetype PKCS12

To export a certificate for inspection or distribution without exporting the private key, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
keytool -exportcert 
  -alias app-server 
  -keystore app.p12 
  -storetype PKCS12 
  -rfc 
  -file app-server-cert.pem

The -rfc option writes the certificate in the familiar PEM-style encoding. It does not convert the keystore and does not expose the private key.

Convert JKS to PKCS12 or PKCS12 to JKS

Use -importkeystore to copy one entry or all entries between stores. Specify both source and destination types; do not depend on a JDK default during migration.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
keytool -importkeystore 
  -srckeystore legacy.jks 
  -srcstoretype JKS 
  -destkeystore modern.p12 
  -deststoretype PKCS12

Without -srcalias, the command can copy all entries. Add -srcalias app-server when only one entry should be migrated. The command prompts for source and destination passwords when they are omitted. After conversion, run -list -v against the destination and verify every alias, entry type, chain length, and fingerprint. A successful file conversion does not guarantee that an application accepts the new format; update the application’s store type and path together.

The reverse migration is the same operation with the types exchanged:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
keytool -importkeystore 
  -srckeystore modern.p12 
  -srcstoretype PKCS12 
  -destkeystore legacy.jks 
  -deststoretype JKS
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Diagnose TLS failures involving a truststore

A message that the truststore does not contain the right certificate usually means the client cannot build a trusted chain for the server certificate. Work through the checks in this order:

  1. Confirm the runtime file: verify the JDK process is using the intended truststore path and store type. A correctly edited file is irrelevant if the application points to another file.
  2. List the active store: run keytool -list -v against that exact path and check that the expected CA alias exists as a trustedCertEntry.
  3. Check the chain: make sure the truststore contains a certificate that can anchor the server’s presented chain. Importing only an unrelated leaf certificate or the wrong intermediate will not help.
  4. Check dates and algorithms: expired certificates, not-yet-valid certificates, and algorithms rejected by the JDK’s security policy can fail even when an alias is present.
  5. Check hostname validation separately: trust establishes the issuer; hostname verification compares the requested host with the certificate’s names. A truststore change cannot fix a name mismatch.
  6. Check the server side: if the client trusts the issuing CA but the server sends only its leaf certificate, the server may need its intermediate chain installed in its identity keystore.

Do not solve an unknown-certificate error by disabling certificate or hostname validation. That removes the protection the truststore is intended to provide. Capture the presented certificate, inspect its issuer and fingerprint, and make the smallest verified trust change necessary.

Change passwords safely

Use -keypasswd to change the password protecting one private-key entry and -storepasswd to change the password protecting the keystore’s integrity. Both commands prompt when passwords are omitted:

keytool -keypasswd 
  -alias app-server 
  -keystore app.p12 
  -storetype PKCS12
keytool -storepasswd 
  -keystore app.p12 
  -storetype PKCS12

A password change does not rotate the key pair or renew a certificate. Those are separate lifecycle operations. Update the application secret configuration at the same time and test a controlled restart before removing the old deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operational practices that prevent avoidable outages

  • Keep passwords out of command lines and scripts: Oracle advises omitting password options so keytool can prompt, except in controlled testing or a securely managed environment. Command-line arguments can be exposed through process listings, shell history, or logs.
  • Back up before imports and conversions: preserve a protected copy of the original keystore, and verify that the backup can be read before changing the live file.
  • Document identity: record the JDK version, store type, path, alias, key algorithm, chain order, certificate fingerprints, and renewal date.
  • Use unique, descriptive aliases: avoid aliases such as 1 or test in production, where multiple certificates may coexist during renewal.
  • Plan overlap for renewal: import and validate a replacement certificate before the current one expires, then switch application configuration deliberately.
  • Limit access: grant read access only to the service account and administrators who need it. Treat private-key backups as sensitive credentials.

Keytool command map

Command Purpose Typical use
-genkeypair Creates a key pair and self-signed certificate. Initial identity keystore setup.
-certreq Creates a PKCS #10 CSR. Requesting a CA-signed certificate.
-importcert Imports a trusted certificate or certificate chain. Adding a CA to a truststore or installing a CA reply.
-list Lists aliases and entries; -v adds certificate details. Auditing contents, chains, and fingerprints.
-printcert Prints certificate contents from a file or supported input. Inspecting a certificate before trust decisions.
-exportcert Exports a certificate, commonly with -rfc for PEM-style output. Sharing a public certificate without its private key.
-importkeystore Copies entries between source and destination keystores. JKS/PKCS12 migration or controlled copying.
-keypasswd Changes one key-entry password. Rotating protection for a private key.
-storepasswd Changes the keystore password. Rotating store-level protection.

A repeatable, safe workflow

For a new Java TLS identity, create a PKCS12 keystore with an explicit alias and store type, generate the CSR from that same alias, verify every CA certificate fingerprint independently, import the returned chain under the original alias, and inspect the resulting PrivateKeyEntry and chain. For a client truststore, import only verified CA certificates as trustedCertEntry entries. During migrations, specify both store types, preserve a backup, and validate the destination with verbose listing before changing the application. These checks address the failures that matter most: wrong format, wrong alias, incomplete chain, untrusted issuer, expired certificate, and accidental use of the wrong file.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.