aldm 0 Junior Poster in Training

Hi,

I have a problems with certificates in j2me.
I need to access web mail using https connection, but there is certificate exception:

javax.microedition.pki.CertificateException: Certificate was issued by an unrecognized entity

I tried to use UserCredentialManager class, but I didn't found detail explanation
how to use this class. Here is a code in j2me:

String nameInfo = new String("CN=az15032");
			 byte[] enrollmentRequest = null;
			 int keyLength = 1024;
			 // User friendly names and prompts.
			 String securityElementID = new String("Bank XYZ");
			 String securityElementPrompt = new String
			 ("Please insert bank XYZ security element before proceeding");
			 String friendlyName = new String("My Credential");
			 // Certificate chain and URI from registration response.
			 byte[] pkiPath=null; 
			 String uri="";     
			 // Obtain a certificate enrollment request message.
			 try {
				 enrollmentRequest = UserCredentialManager.generateCSR
				 (nameInfo, UserCredentialManager.ALGORITHM_RSA, keyLength,
				 UserCredentialManager.KEY_USAGE_NON_REPUDIATION, 
				 securityElementID, securityElementPrompt, false);
				 // Send it to a registration server.
				 // Assign values for pkipath and certificate uri
				 // from the registration response.
				 // Store the certificate on the security element.
				 UserCredentialManager.addCredential(friendlyName,pkiPath, uri);
			 } 
			 catch (IllegalArgumentException iae) {
				 iae.printStackTrace();
			 } 
			 catch (NullPointerException npe) {
				 npe.printStackTrace();
			 } 
			 catch (CMSMessageSignatureServiceException cmse) {
				 cmse.printStackTrace();
			 } 
			 catch (UserCredentialManagerException pkie) {
				 pkie.printStackTrace();
			 }

So, can anyone tell me how can I send CSR request to the registration server
and get pkipath and uri values from response?

If someone could give me example how to use this code for getting certificate
from webiste https://some-website.com with username some_username, it would be the best.

I appreciate any kind of help related to this topic.

Thanks in advance,

Amer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.