2012-05-31 31 views
8

Mi chiedevo se esiste una specifica ufficiale del formato di keystore JKS utilizzato in Java? Mi piacerebbe scrivere un convertitore da/a PKCS # 12, ma non in Java, quindi keytool o codice Java non è un'opzione, purtroppo.Specifica del formato di keystore JKS

Guardare uno in un editor esadecimale mi dice che probabilmente non è ASN.1. Prima di iniziare a scavare in OpenJDK, provando a decodificare il formato, qualcuno sa se esiste una specifica? Non ho trovato nulla finora, qualsiasi aiuto sarebbe molto apprezzato!

risposta

12

Penso che dovresti iniziare la tua ricerca su JDK sources. Ci sono alcuni commenti molto utili lì. E.g.

/* 
     * KEYSTORE FORMAT: 
     * 
     * Magic number (big-endian integer), 
     * Version of this file format (big-endian integer), 
     * 
     * Count (big-endian integer), 
     * followed by "count" instances of either: 
     * 
     *  { 
     *  tag=1 (big-endian integer), 
     *  alias (UTF string) 
     *  timestamp 
     *  encrypted private-key info according to PKCS #8 
     *   (integer length followed by encoding) 
     *  cert chain (integer count, then certs; for each cert, 
     *   integer length followed by encoding) 
     *  } 
     * 
     * or: 
     * 
     *  { 
     *  tag=2 (big-endian integer) 
     *  alias (UTF string) 
     *  timestamp 
     *  cert (integer length followed by encoding) 
     *  } 
     * 
     * ended by a keyed SHA1 hash (bytes only) of 
     *  { password + whitener + preceding body } 
     */