Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8775677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:51:55+00:00 2026-06-13T18:51:55+00:00

I am attempting to use client certificates for an SSL connection using MonoTouch. There

  • 0

I am attempting to use client certificates for an SSL connection using MonoTouch. There seems to be several examples to do this using objective-c, and the solution I am looking for would probably be similar the one answered here but in MonoTouch (C#).

I am using the NSUrlConnection class in MonoTouch, and have overridden the NSUrlConnectionDelegate class to respond to the authentication challenge.

I have been able to load the certificates from file, but I have been unable to find a useful representation of the certificates to respond to the authentication challenge.

public override void ReceivedAuthenticationChallenge(NSUrlConnection connection, NSUrlAuthenticationChallenge challenge)
{
   if (string.Equals(challenge.ProtectionSpace.AuthenticationMethod, "NSURLAuthenticationMethodClientCertificate", StringComparison.OrdinalIgnoreCase)) {
      string password = "<password_signed_certificate>";
      byte[] data = File.ReadAllBytes("<path_of_file_in_ios_sandboxed_filesystem_pkcs>");
      NSDictionary opt = NSDictionary.FromObjectsAndKeys(new object[]{password}, new object[]{"passphrase"});
      NSDictionary[] items;
      SecStatusCode stat = SecImportExport.ImportPkcs12(data, opt, out items); // Uses MonoTouch.Security namespace
      MonoTouch.Security.SecTrust trust = (MonoTouch.Security.SecTrust)items[0]["trust"];
      // Everything to this point works, and I can inspect the trust object that all the expected certificate properties (IssuerName etc.) are correct

      IntPtr secTrustRef = trust // ????? How do I bridge this gap
      // NSUrlConnection does not utilise MonoTouch security namespace

      NSUrlCredential cred = new NSUrlCredential(secTrustRef, true);
      challenge.Sender.UseCredentials(cred, challenge);
   }
}

Some notes:

  1. I have seen the objective-c solutions but I have not found the equivalent set of steps required in MonoTouch (C#).
  2. I cannot utilise HttpWebRequest, as the monotouch implementation of httpWebRequest.ClientCertificates (a collection) throws a ‘not implemented exception’.
  3. I have also attempted to use the Mono.Security.X509 and System.Security.Cryptography.X509Certificates namespaces to open the certificates with success, but again I cannot utilise the class instances to respond to the Authentication challenge, as I need to create a NSUrlCredential object which only accepts an IntPtr.
  4. See also this.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:51:57+00:00Added an answer on June 13, 2026 at 6:51 pm

    Use HttpWebRequest. In the question notes point 2 I said the HttpWebRequest.ClientCertificates property throws a not implemented exception, and I therefore ruled out this option. It does if you try to set it the property with a new collection, but if you just use the Get accessor, you can add a client certificate to the collection.

    As a side note, using HttpWebRequest makes the app more transportable to other devices, part of the reason we are using MonoDevelop so win-win.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to use the HTML5 Boilerplate system (http://html5boilerplate.com/) for a client's website,
Attempting to use the data series from this example no longer passes the JSONLint
I am attempting to use the following code to search a database using words
I'm attempting to use the rest-client gem to post something, but for some reason,
I'm attempting to use the Java Selenium client with JBehave to interact with a
I'm attempting to use inet's tftp, but I'm doing something incorrectly. This simple example
I'm attempting to use the SQL Server SMO library from Python 2.7 using pyWin32.
I'm having some difficulty attempting to create an SSL socket in Python to use
I am attempting to create a telnet client that I can use to transfer
I'm attempting to extend this answer on SO to make a WCF client retry

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.