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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:29:49+00:00 2026-05-31T10:29:49+00:00

I receive an error when trying to get a certificate hash from a remote

  • 0

I receive an error when trying to get a certificate hash from a remote machine using the following code:

private string getCertHash(string Hostname)
{
    string result = "";

    using (ServerManager serverManager = ServerManager.OpenRemote(Hostname))
    {
        SiteCollection siteCollection = serverManager.Sites;
        foreach (Site site in siteCollection)
        {
            foreach (Binding binding in site.Bindings)
            {
                if (binding.Protocol == "https")
                {
                    // Error here
                    foreach (Byte certhashbyte in binding.CertificateHash)
                        result += certhashbyte.ToString(); 
                }
            }
        }
    }

    return result;
}

The error I receive in more detail:

‘binding.certhashbyte’ threw an exception of type
‘System.Runtime.InteropServices.COMException’

Either the application has not called WSAStartup, or WSAStartup
failed. (Exception from HRESULT: 0x8007276D)

If I replace the following row:

using (ServerManager serverManager = ServerManager.OpenRemote(Hostname))

with

using (ServerManager serverManager = new ServerManager)

to use the local server it works fine.

Note that using ServerManager.OpenRemote(Hostname) works in general (I get all the other information, just the CertHash info results in an error. I have admin rights on both machines (local and remote). System is Windows 2008 R2 using IIS 7.5.

Please tell me what I’m doing wrong / what is missing / why the error occurs.

  • 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-31T10:29:50+00:00Added an answer on May 31, 2026 at 10:29 am

    For some reason the code above now works fine. I couldn’t find out why it did not work, but I did find some alternatives I want to share:

    1. Using this code and here an example usage:

      CertStoreReader certStoreReader = new CertStoreReader();
      foreach (X509Certificate2 x509 in certStoreReader.GetCertificates(credentials.Hostname))
      {
          certHash = x509.GetCertHashString();
      }
      
    2. Using the ServerManager as first tried above (in the question)

      using (ServerManager serverManager = ServerManager.OpenRemote(server))
      {
          Site site = serverManager.Sites.Where(s => s.Name == websiteName).Single();
          foreach (Binding binding in site.Bindings)
          {
              certHash += BitConverter.ToString(binding.CertificateHash).Replace("-", string.Empty);      
          }              
      }
      
    3. Using DirectoryEntry

      DirectoryEntry dir = new DirectoryEntry(@"IIS://" + server + @"/W3SVC/" + siteID);
      PropertyValueCollection vals = dir.Properties["SSLCertHash"];
      foreach (string entry in vals)
      {
          certHash += entry;
      }
      
    4. Using WMI. I used this query in the WebAdministration namespace:

      "SELECT CertificateHash FROM SSLBinding WHERE IPAddress = '" + IP + "' AND Port = " + port
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I receive the following error when trying to run my ASP.NET MVC application: The
Using HttpClient , I receive the following error when attempting to communicate over HTTPS:
I'm trying to write a SSL-based async server using Boost ASIO example code from
I am trying to get the following piece of code to work in a
I receive the following exception while attempting to log an error using Enterprise Library
I'm using subclipse in Flex Builder 3, and recently received this error when trying
Why do I receive a syntax error when printing a string in Python 3?
When I launch CruiseControl.NET with a particular configuration file I receive the following error:
How can I correct the following so that I don't receive a syntax error
I am trying to make my first AJAX Control and I get error. I

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.