Wednesday, April 10, 2013

[android-developers] Trust chain certificates to access https service in Android

Dear...

I need to access a server with a public certificate created by a government institute.

I loaded the server certificate in .DER format, but it does not load a trust chain of this certificate (message: Trust anchor for certification path not found).

The root CA is not in System CA Trust Store. 

How to load a trust chain?
Is possible to load a p7b file in the Android?

My code:
public void carregaCertificado(String nmArquivo)
throws CertificateException, KeyStoreException, IOException {
{

FileInputStream fis = null;
fis = new FileInputStream(nmArquivo);

BufferedInputStream bis = new BufferedInputStream(fis);

CertificateFactory cf = CertificateFactory.getInstance("X.509");

while (bis.available() > 0) {
Certificate cert = cf.generateCertificate(bis);
ksServer.setCertificateEntry(nmArquivo, cert);
}

}
}

Thanls
mbarbiero

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment