
22/01/2009, 06:40
|
| | Fecha de Ingreso: enero-2009
Mensajes: 1
Antigüedad: 16 años, 1 mes Puntos: 1 | |
Como Acceder al KeyStore de Firefox Hola:
Necesito listar los certificados personales del KeyStore de Firefox, ya he hecho esto facilmente para IE con java6.
Mi problema ocurre cuando se ejecuta esta instruccion:
Provider nss = new sun.security.pkcs11.SunPKCS11("c:/test/test2.cfg");
Por lo que ni siquiera cargo el KeyStore.
Mi codigo :
public static void main(String[] args) throws KeyStoreException, CertificateException {
try {
//
System.load("c:/test/libnspr4.dll");
System.load("c:/test/libplc4.dll");
System.load("c:/test/libplds4.dll");
System.load("c:/test/softokn3.dll");
//
Provider nss = new sun.security.pkcs11.SunPKCS11("c:/test/test2.cfg");
Security.insertProviderAt(nss, 1);
KeyStore ks = KeyStore.getInstance("PKCS11", nss);
ks.load(null, null);
Enumeration aliases = ks.aliases();
String alias = null;
while (aliases.hasMoreElements()) {
alias = (String) aliases.nextElement();
System.out.println(alias);
}
Security.removeProvider(nss.getName());
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.S EVERE, null, ex);
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(Main.class.getName()).log(Level.S EVERE, null, ex);
}
}
//////////////////////////////
El archivo test.cfg contiene:
name = NSS
slot = 2
library = C:/test/softokn3.dll
nssArgs = "configdir='c:/Documents and Settings/User/Datos de programa/Mozilla/Firefox/Profiles/aoyomgvn.default' certPrefix='' keyPrefix=''
secmod='secmod.db' flags=readOnly"
/////////////////////////////////////////////
El error al ejecutar:
run:
Exception in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.jav a:340)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.jav a:86)
at firma.Main.main(Main.java:164)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at sun.security.pkcs11.wrapper.PKCS11.C_Initialize(Na tive Method)
at sun.security.pkcs11.wrapper.PKCS11$SynchronizedPKC S11.C_Initialize(PKCS11.java:1488)
at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKC S11.java:160)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.jav a:297)
... 2 more
Java Result: 1
Agradeceria cualquier tipo de ayuda, o me gustaria saber si lo hay que hacer de otra manera.
Gracias |