Key Stores

For managing Java key stores, I suggest using KeyStore Explorerarrow-up-right.

All methods below are available as static imports from com.mirkocaserta.bruce.Keystores.

Default

KeyStore keystore();

Returns the default key store using configuration from the following system properties:

  • javax.net.ssl.keyStore

  • javax.net.ssl.keyStorePassword

The key store location supports the following protocols:

  • classpath:

  • http:

  • https:

  • file:

If no protocol is specified, file is assumed. The default key store type is PKCS12.

Usage Example

KeyStore keystore = keystore();

Default with Type

Same as above but the key store type can be specified. For instance, valid types include: JKS, PKCS12.

Usage Example

From Location

Loads a key store from the given location.

The location parameter supports the protocols described in the default key store section.

The key store is opened with the given password. The key store type is assumed to be the default: PKCS12.

Usage Examples

From Location with Type

Same as from location but allows you to specify a key store type.

Usage Examples

From Location with Type and Provider

Same as above but allows specifying an explicit JCA provider.

Usage Example

Serialization

Serializes an in-memory key store so you can persist it in different forms:

  • raw bytes for transport or custom storage

  • encoded text using HEX, BASE64, URL, or MIME

  • direct file output to Path or File

Usage Examples

Last updated

Was this helpful?