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

  • Home
  • SEARCH
  • 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 8877177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:23:59+00:00 2026-06-14T19:23:59+00:00

I have a cURL command that requires a security certificate. I am trying to

  • 0

I have a cURL command that requires a security certificate. I am trying to replace the call with a WebRequest in C#.

Here’s the curl command :

curl -d “uid=UUUUUU&password=PPPPPP&active=Y&type=I” https://www.aidap.naimes.faa.gov/aidap/XmlNotamServlet –key aidap_key.pem –cacert aidap_ca.pem –cert aidap_client.pem:start123 -k -O

Where I am stuck is with how to incorporate the –key, –cacert and –cert parameters. Currently I am setting WebRequest.PreAuthenticate=true and creating NetworkCredential with the name and password of the security certificate in my certificate store (what I assume is in the –key, –cacert, etc).

I am getting a 403 forbidden exception when I run the code below.

Any ideas?

Here’s the code I’m using:

 public void RetrieveNotams()
        {
            string myURL = "https://www.aidap.naimes.faa.gov/aidap/XmlNotamServlet";

            HttpWebRequest req;

            NetworkCredential myCred = new NetworkCredential("AAAAA", "BBBBB");

            req = (HttpWebRequest)WebRequest.Create(myURL);

            req.PreAuthenticate = true;

            req.Credentials = myCred;

            req.Method = "POST";

            req.ContentType = "application/x-www-form-urlencoded";
            string postData = "uid=UUUUUU&password=PPPPPP&active=Y&type=I";
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            req.ContentLength = byteArray.Length;

            using (Stream dataStream = req.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
            }

            req.GetResponse();

        }
  • 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-14T19:24:00+00:00Added an answer on June 14, 2026 at 7:24 pm

    I figured it out with the help of

    http://www.codeproject.com/Articles/28395/Attaching-a-digital-certificate-public-key-to-an-H

    I grab the certificate from the certificate store, and add it to the request’s certificate collection. And took out the PreAuthenticate code.

    Here’s the updated code:

    public void RetrieveNotams()
    {
        string myURL = "https://www.example.com/SecureSite";
    
        // Open the certificate store for the current user in readonly mode,
        // and find the certificate I need to user
        X509Store xstore = new X509Store(StoreLocation.CurrentUser);
    
        xstore.Open(OpenFlags.ReadOnly);
    
        X509Certificate cert=null; 
    
        foreach (X509Certificate c in xstore.Certificates)
            if(c.Subject.StartsWith("CN=aidapuser"))
                cert=c;          
    
        HttpWebRequest req;
    
        req = (HttpWebRequest)WebRequest.Create(myURL);
    
        // add the certificate to the request
        req.ClientCertificates.Add(cert);
    
        req.Method = "POST";
    
        req.ContentType = "application/x-www-form-urlencoded";
        string postData = "uid=UUUUUUU&password=PPPPPP&active=Y&type=I";
        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        req.ContentLength = byteArray.Length;
    
        // add the parameters to POST to the URL
        using (Stream dataStream = req.GetRequestStream())
        {
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();
        }
    
        // grab the response and show the first 10 lines
    
        using (StreamReader sr = new StreamReader(req.GetResponse().GetResponseStream()))
        {
    
            for (int i = 0; i < 10; i++)
                Console.WriteLine(sr.ReadLine());
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this command that is using a unix pipe system(curl . escapeshellarg($flv['dl']) .
I have a curl command that needs to make a post and send my
I have the following curl command that works perfectly from the windows command line:
I have read that CURL is way too fast than File Get Contents and
I have a PHP script that uses CURL to fetch a remote page and
I have a django view that returns HTTP 301 on a curl request: grapefruit:~
I have a need to rename a file after download using php cURL. Here's
I have a site that uses cURL to access some pages, stores the returned
Scenario: I have a Grails app that uses Acegi security for authentication. I'm implementing
I have downloaded cURL for Windows from here . I selected the Win64 -

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.