Certobj.dll

by beakerman29 at 2012-10-31 10:20:28

So my question is pertaining to using an interop dll. I have built a class to inventory an IIS 6 web server ( I know move to IIS 7+ which we are :slight_smile: But in the interim I would like to be able to inventory a web server and pull all the good details. The problem that I am running into is figuring out what SSL certificate a particular website is using. I have created an interop dll using the tlbimp.exe as recommended here http://stackoverflow.com/questions/4585809/programmatically-assigning-an-existing-ssl-cert-to-a-website-in-iis6-via-powersh I created mine and called it interop.certobj.dll so when I do the following I get an error that it can’t find the type
[void][reflection.assembly]::loadfrom(“d:\scripts\powershellmodules\Interop.certobj.dll”)
$certMgr = New-Object -TypeName certobj.IISCertObjClass


I’m sure I haven’t done something right as this is my first time playing with an interop I have had to create this way so any help is appreciated. I did open my class up in VS 2010 and browsed and I do see the class there as well.
by DonJ at 2012-11-05 12:00:44
This is probably more of a programming thing than an IIS thing; you might ping Kirk in the Advanced forum. In fact, StackOverflow wouldn’t be a bad place to ask, either - you’re pretty deep into the ghetto side of the .NET Framework ;). It certainly appears as if the DLL you’ve built either isn’t correctly built, or isn’t being recognized in PowerShell.
by JasonHelmick at 2012-11-06 06:42:07
Hi Beakerman29!

I totally agree with Don on this, but I just wanted to add that one way to discover what certificate a website is using might be something like this:

This gets the thumbprint of the websites certificate from the SSLBindings:

PS> $Thumb=get-childitem -path IIS:\SslBindings | Where-Object {$_.host -like “test”} | Select-Object -ExpandProperty ThumbPrint
Note- In the where-object it could be host, IPaddress or port -

This grabs the certificate that matches the thumb print.
PS> get-childitem -Path Cert:\LocalMachine\My$Thumb | fl *

Hope this helps!

Jason
by JasonHelmick at 2012-11-06 06:54:06
Oh! I almost forget…if you are going to try some version of the example above make sure to import the WebAdministration module so you get the IIS: provider. This all works over PowerShell remoting as well, so you can run it against multiple servers.

Cheers!

Jason