Wednesday, September 2, 2009

Add certificate to keystore in blackberry mobile device

In blackberry applications when we establish connection with server that asks for
security certificate.To over come this problem we can add certificate and trust the application
using this method.To save certificate within application you can use my early post regarding
the store file within an application to store infomation.
This method add certificate to keystore when it runs

public void addCertToDeviceKeyStore (Certificate certificate)
{
KeyStore keyStore = DeviceKeyStore.getInstance();
//check if certificate is not already in the DeviceKeyStore
if (!keyStore.isMember(certificate))
{
try {
keyStore.set(null,certificate.getSubjectFriendlyName(),certificate,certificate.getStatus(),
keyStore.getTicket());
}
catch (Exception e)
{
\\error message
}
}

No comments:

Post a Comment