JksKeyStore class

A Java KeyStore in the JKS (0xFEEDFEED) or JCEKS (0xCECECECE) format, as written by sun.security.provider.JavaKeyStore and com.sun.crypto.provider.JceKeyStore.

Layout (big-endian):

magic · version (1 or 2) · count · entries · SHA-1 digest
  • private key (tag 1): alias · date · protected key · chain
  • trusted certificate (tag 2): alias · date · certificate
  • certificate: type (version 2 only) · length · DER

The digest is SHA-1(UTF-16BE(password) · "Mighty Aphrodite" · body). Private keys are kept as loaded (protected) until JksPrivateKeyEntry.decrypt is called, and written back untouched when they were never decrypted.

Inheritance

Constructors

JksKeyStore.empty({String storeType = 'jks'})
An empty store to fill and save (storeType 'jks' or 'jceks').
factory

Properties

certs → Map<String, TrustedCertEntry>
Returns all trusted certificate entries.
no setterinherited
entries → Map<String, KeystoreEntry>
Map of aliases to entries.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
privateKeys → Map<String, PrivateKeyEntry>
Returns all private key entries.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
storeType → String
The type of keystore (e.g., "jks", "jceks", "bks").
finalinherited

Methods

getAllCertificates() → List<Uint8List>
Gets all certificates from the keystore as DER-encoded bytes.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save(String storePassword, {String? keyPassword}) → Uint8List
Saves the keystore in the JKS format.
saveJceks(String storePassword, {String? keyPassword}) → Uint8List
Saves the keystore in the JCEKS format (PBEWithMD5AndTripleDES keys).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

load(Uint8List bytes, {String storePassword = ''}) → JksKeyStore
Loads a JKS or JCEKS keystore from bytes.