Reputation: 38465
Well i have a web page hosted in a IIS 7.0 now the problem here is that we have many different domains that can be used to visit it, but we only have a cert(SSL) for a handful of them.
When you visit the login page i would like to change to https if they use a domain where we do have a ssl cert..
But is there any way to determine if there is a ssl cert for that domain or not?
Upvotes: 0
Views: 322
Reputation: 12351
...handful of them...
If you're going to consider doing the extra work of querying your certificate store (for a "handful"), why not simplify and compare Request.Url
against a list of domains that you know you have certificates for?
Upvotes: 1
Reputation: 2652
Have a look at http://msdn.microsoft.com/en-us/magazine/cc163454.aspx.
You would most likely search by subject name (using the current domain.)
If you find a certificate, redirect to https.
Just a note: This will not return whether or not the certificate is assigned to the site in IIS, only whether it is installed on the local machine.
Additionally you could check that the certificate has private key information to add some robustness to the process (Avoid finding a certificate that is unable to ventbe used by IIS)
Upvotes: 0