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 4553352
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:56:02+00:00 2026-05-21T16:56:02+00:00

I wan’t to examine a Webpage which requires Client Side Certificate Authentication. How can

  • 0

I wan’t to examine a Webpage which requires Client Side Certificate Authentication.
How can i provide my Cert from the Certstore to the Webrequest:
Is there a way to specify this in Credentials odr within the Proxy?

$webclient = New-Object Net.WebClient
# The next 5 lines are required if your network has a proxy server
$webclient.Credentials = [System.Net.CredentialCache]::DefaultCredentials
if($webclient.Proxy -ne $null)     {
    $webclient.Proxy.Credentials = `
            [System.Net.CredentialCache]::DefaultNetworkCredentials
}
# This is the main call
$output = $webclient.DownloadString("$URL") 

PS: Maybe this helps: How can you add a Certificate to WebClient (C#)? But i don’t get it.. 😉

  • 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-05-21T16:56:02+00:00Added an answer on May 21, 2026 at 4:56 pm

    Using the new Add-Type functionality in PowerShell v2, you can craft a custom class that you can then use to make your typical WebRequest. I have included a method on the custom class to allow you to add certificates that can be used for authentication.

    PS C:\> $def = @"
    public class ClientCertWebClient : System.Net.WebClient
    {
        System.Net.HttpWebRequest request = null;
        System.Security.Cryptography.X509Certificates.X509CertificateCollection certificates = null;
    
         protected override System.Net.WebRequest GetWebRequest(System.Uri address)
         {
             request = (System.Net.HttpWebRequest)base.GetWebRequest(address);
             if (certificates != null)
             {
                 request.ClientCertificates.AddRange(certificates);
             }
             return request;
         }
    
         public void AddCerts(System.Security.Cryptography.X509Certificates.X509Certificate[] certs)
         {
             if (certificates == null)
             {
                 certificates = new System.Security.Cryptography.X509Certificates.X509CertificateCollection();
             }
             if (request != null)
             {
                 request.ClientCertificates.AddRange(certs);
             }
             certificates.AddRange(certs);
         }
     }
     "@
    
    PS C:\> Add-Type -TypeDefinition $def
    

    You would perhaps want to limit the certificates being added to just the one (or ones) you would want to use rather than just use every available certificate in the Current User store, but here is an example that just loads all of them:

    PS C:\> $wc = New-Object ClientCertWebClient
    PS C:\> $certs = dir cert:\CurrentUser\My
    PS C:\> $wc.AddCerts($certs)
    PS C:\> $wc.DownloadString("http://stackoverflow.com")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wan't a method with which to find a string within another string. It
I wan't to know the real size of a web page (HTML + CSS
I wan't to change the background color of a div dynamicly using the following
I wan't to hide/show menuitems in a contextmenu using some propery of databound object.
A number of stored procedures I support query remote databases over a WAN. The
I wan to place a VB.NET project under Git control in Windows (was previously
I wan't to customize the icon displayed within the windows 7 taskbar. When my
I wan to check if my stateful bean is passivated/activated and the corresponding callbacks
I wan't people to be able to register their own sections within my site,
I wan't to search a filename for example like this string: $filetype = file.php.jpg;

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.