i am trying to create a certificate for google marketplace app. i am trying to implement a interface http://code.google.com/p/step2/source/browse/code/java/trunk/common/src/main/java/com/google/step2/xmlsimplesign/TrustRootsProvider.java?r=383
my sourcecode is
public class AppEngineTrustsRootProvider implements TrustRootsProvider {
private static final String CERT_FILE = "/cacerts.bin";
private final Collection<X509Certificate> certs;
@SuppressWarnings("unchecked")
public AppEngineTrustsRootProvider() {
try {
ObjectInputStream in =
new ObjectInputStream(AppEngineTrustsRootProvider.class.getResourceAsStream(CERT_FILE));
certs = (Collection<X509Certificate>) in.readObject();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
public Collection<X509Certificate> getTrustRoots() {
return certs;
}
}
i read this article in which using openssl or keytool we can generate certificate in .cert file or in .der file but how to get list of certificates in .bin file . this is an example code snippet i am unable to figure it out how to get list of certificates in .bin file . please some one help
If I understand your question correctly, you are trying to get a group of certs together into a file. This is often done through a KeyStore file, which can be of several formats. Two popular formats are JKS and PKCS12. You can use the Java
keytool
command oropenssl
to create the keystores.Then programmatically, you can load the keystore file into a Java KeyStore object. From there you can use the
aliases()
method to retrieve all the aliases in the KeyStore. Then you can go through each one with theisCertificateEntry(alias)
method, and if true, add the resulting certificate fromgetCertificate(alias)
into a Collection, that you will return at the end of the method. There is some example code for loading a KeyStore from a file at the KeyStore link above.Note that the
cacerts
file present in JRE installations is actually a JKS keystore.