« Previous Next »

Thread: How to read the SSL Hash using MWA?

Last post 05-26-2009 11:39 PM by brady.gaster. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 05-26-2009, 10:58 AM

    How to read the SSL Hash using MWA?

    I am using MWA to create FTP sites on an IIS 7 machine, as is outlined at this other forum post - http://forums.iis.net/t/1150298.aspx. The code below, which performs the function of "setting" the server certificate hash value in the configuration, works perfectly.

    sslElement["serverCertHash"] = ConfigurationManager.AppSettings["FtpServerCertHash"];
    sslElement["controlChannelPolicy"] = "SslAllow";
    sslElement["dataChannelPolicy"] = "SslAllow";

    The problem I have, however, is that I'll be creating numerous sites using this code on various servers, and the use of the appSetting isn't realistic.  What I need the code to do, at run-time, is to ask the targeted server "could you please tell me your SSL cert?" I'll use the value given to me by the server in the code. In this way, numerous FTP sites will use the same key, but the key will be variant from server to server.

    The idea here is to automate the selection of an SSL key, as is provided by the "SSL Certificate" in the "FTP SSL Settings" section of the IIS Manager, and to pre-select the first item in the list, but to do it programmatically at the time the FTP site is created.

    Is this possible, and if so, can it be done using MWA or MWM? 

  • 05-26-2009, 5:35 PM In reply to

    Re: How to read the SSL Hash using MWA?

    You can probably build something by using the X509Store and its Certificates collection, and use X509Certificate2 to set the hash.

    Something like:

    X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
    store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
    foreach (X509Certificate2 certificate in store.Certificates) {
        // check to see if it has the right settings and display it in a picker...
    }

    When selected just use the GetCertHash methods.

     

  • 05-26-2009, 11:39 PM In reply to

    Re: How to read the SSL Hash using MWA?

     Thanks Carlos. Not trying to get down-and-specific, but this will be executing remotely, so the StoreLocation.LocalMachine parameter would have to be changed. I'll investigate this class a little more thoroughly but in the meantime, if you have any guidance I'm all ears.

Page 1 of 1 (3 items)
Microsoft Communities