Welcome to the Windows Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 1 of 1
  1.    #1  
    I'm porting a small piece of Java that will fetch HTML from a secured web
    page. The Java code was purposely written to accept any client
    certificate - even out of date certificates. This was accomplished by
    implementing an X509TrustManager that accepted any certificate.

    I'm trying to understand how to do the equivalent in Windows Phone with C# (Visual Studio).

    Does anyone know how to do this? Help would be very much appreciated.
    Thanks in advance.

    I have an example code, but X509Store and X509Certificate2Collection doesn't exist in Windows Phone...

    using System;
    using System.Security.Cryptography;
    using System.Security.Cryptography.X509Certificates;

    public class CertSelect
    {
    public static void Main()
    {
    try
    {
    X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
    store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);

    X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
    for (int i = 0; i < collection.Count; i++)
    {
    foreach (X509Extension extension in collection[i].Extensions)
    {
    Console.WriteLine(extension.Oid.FriendlyName + "(" + extension.Oid.Value + ")");


    if (extension.Oid.FriendlyName == "Key Usage")
    {
    X509KeyUsageExtension ext = (X509KeyUsageExtension)extension;
    Console.WriteLine(ext.KeyUsages);
    }

    if (extension.Oid.FriendlyName == "Basic Constraints")
    {
    X509BasicConstraintsExtension ext = (X509BasicConstraintsExtension)extension;
    Console.WriteLine(ext.CertificateAuthority);
    Console.WriteLine(ext.HasPathLengthConstraint);
    Console.WriteLine(ext.PathLengthConstraint);
    }

    if (extension.Oid.FriendlyName == "Subject Key Identifier")
    {
    X509SubjectKeyIdentifierExtension ext = (X509SubjectKeyIdentifierExtension)extension;
    Console.WriteLine(ext.SubjectKeyIdentifier);
    }

    if (extension.Oid.FriendlyName == "Enhanced Key Usage")
    {
    X509EnhancedKeyUsageExtension ext = (X509EnhancedKeyUsageExtension)extension;
    OidCollection oids = ext.EnhancedKeyUsages;
    foreach (Oid oid in oids)
    {
    Console.WriteLine(oid.FriendlyName + "(" + oid.Value + ")");
    }
    }
    }
    }
    store.Close();
    }
    catch (CryptographicException)
    {
    Console.WriteLine("Information could not be written out for this certificate.");
    }
    }
    }

Similar Threads

  1. IMAP "certificate not valid" error message
    By gideongrimes in forum Windows Phone 7
    Replies: 8
    Last Post: 09-03-2013, 07:44 AM
  2. Connect to wireless network using certificate
    By mapexvenus in forum Windows Phone 7
    Replies: 1
    Last Post: 11-07-2011, 11:26 AM
  3. WiFi - install wireless certificates HELP
    By ultraprism in forum Windows Phone 7
    Replies: 2
    Last Post: 11-01-2011, 12:57 PM
  4. WP7 and certificates
    By Endosmok in forum Windows Phone 7
    Replies: 1
    Last Post: 09-01-2011, 11:45 AM

Posting Permissions