Wednesday, 14 September 2011

SSL woes, .NET framework to the rescue.

We have been struggling with some SSL issues and I remembered that last time we had similar issues, on a different project, the .NET built-in trace logging was a life saver, as it allowed to see what was going in, so I thought I would post this here.
All that is needed is to add the following to your app.config file and make sure that the account running the app has the right permissions:

        <trace autoflush="true" />
                <source name="System.Net" maxdatasize="1024">
                        <add name="mytracefile"/>
              <source name="System.Net.Sockets" maxdatasize="1024">
                        <add name="mytracefile"/>
                <add name="mytracefile" type="System.Diagnostics.TextWriterTraceListener"
                  initializeData="c:\ssltrace.log" />
                <add name="System.Net" value="Verbose" />
              <add name="System.Net.Sockets" value="Verbose" />

Original source can be found here.

Note, that you can also have this on your web.config to see what happens on the other end, but note that this is of limited utility for diagnosing SSL issues, as it will only log anything once the SSL handshake has completed.

No comments:

Post a Comment