Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client Certificates Windows Phone 8.1

Does Windows Phone 8.1 support adding a client certificate to an HTTP web request? I'm trying to do something similar to the following, but I can't seem to determine what (if any) is the equivalent to this on WP8.1:

System.Net.HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.ClientCertificates.Add(certificate);

Thanks.

like image 515
user1886316 Avatar asked May 26 '14 22:05

user1886316


People also ask

How do I enable client authentication certificate?

On the taskbar, click Start, and then click Control Panel. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off. Expand Internet Information Services, then select Client Certificate Mapping Authentication, and then click OK.

How do I find device Certificates?

The Certificate Manager tool for the local device appears. To view your certificates, under Certificates - Local Computer in the left pane, expand the directory for the type of certificate you want to view. To view certificates for the current user, open the command console, and then type certmgr. msc.

Where are device Certificates stored?

On iOS, certificates are stored in the publisher keychain. On Android, they are stored in the system keychain.


1 Answers

I assume that you have already put the client certificate in app certificate store. If not this is how you will have to do that 1) Download the PFX file. 2) Install it in the App's certificate store using the following way

await CertificateEnrollmentManager.ImportPfxDataAsync(certString, "Your_PFX_Password", ExportOption.Exportable, KeyProtectionLevel.NoConsent, InstallOptions.None, friendlyName);

3) The next step is to look for the certificate in certificate store. This is done as below

CertificateQuery certQuery = new CertificateQuery();
certQuery.FriendlyName = friendlyName;
IReadOnlyList<Certificate> certs = await CertificateStores.FindAllAsync(certQuery)

The certs[0] will have the certificate

4) To attach the certificate to HTTP request

HttpBaseProtocolFilter protolFilter = new HttpBaseProtocolFilter();
protolFilter.ClientCertificate = certs[0] //from previous step
HttpClient client = new HttpClient(protolFilter)

Point to note is you should not use System.Net.htpp.HttpClient. Instead you should you Windows.Web.Http.HttpClient.

like image 179
Venkatesh Avatar answered Sep 30 '22 06:09

Venkatesh