Sending a certificate with Android?

I've been using CURL and php to send the following:

$ch = curl_init($url);
curl_setopt_array($ch, array(
    CURLOPT_POST => count($postfields),
    CURLOPT_POSTFIELDS => $postfields,
    CURLOPT_SSL_VERIFYPEER => false,  
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_VERBOSE => true,    
    CURLOPT_SSLCERT => 'C:\mycert.pem',
    CURLOPT_SSLCERTPASSWD => 'mypass', 
    CURLOPT_SSLCERTTYPE => 'PEM'
));

I've not included the postfields to keep it brief.

This works very well. However after much googling I can't find a simple way to do this using HTTPClient. I just want to include a certificate with the POST.

TIA

Answers


You need to create a trust store containing your certificate.

My blog post at http://blog.chariotsolutions.com/2013/01/https-with-client-certificates-on.html contains a little more than you need (it includes supporting self-signed client and server certs), but should give you everything you need.


Need Your Help

handle social networks authentication with own API backend

rest authentication oauth social-networking backend

How can I handle authentication via OAuth for some social networks in my own backend?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.