Has anyone had success storing and retrieving a PKCS12 keystore in OpenLDAP?
I store the keystore in a ByteArrayOutputStream, then store the bytes in
OpenLDAP. The bytes get stored, but as a string. When I retrieve the string,
it's almost right, but any negative bytes have been replaced with decimal
63. Here's a snippet of the store:
KeyStore ks = ...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ks.store(baos, keystorePassphrase.toCharArray());
Attribute newattr = new BasicAttribute(pkcs12Name, baos.toByteArray());
attrs.put(newattr);
ctx.modifyAttributes(dn, DirContext.ADD_ATTRIBUTE, attrs);
Here's the retrieval:
Attribute attr = attrs.get(pkcs12Name);
String o = (String)attr.get();
byte[] bytes = (byte[]) o.getBytes();
ByteArrayInputStreambais = new ByteArrayInputStream(bytes);
KeyStore ks = KeyStore.getInstance("PKCS12", "BC");
ks.load(bais, keystorePassphrase.toCharArray());
jmc - 30 Jan 2004 14:05 GMT
Never mind - we figured it out.
> Has anyone had success storing and retrieving a PKCS12 keystore in OpenLDAP?
> I store the keystore in a ByteArrayOutputStream, then store the bytes in
[quoted text clipped - 18 lines]
> KeyStore ks = KeyStore.getInstance("PKCS12", "BC");
> ks.load(bais, keystorePassphrase.toCharArray());