C# Secure Sockets (SSL)
- by Matthias Vance
LS,
I was planning on writing a wrapper around the System.Net.Sockets.Socket class, because I didn't feel like using the SSLStream class because I wanted to maintain backwards compatibility with other programs.
I found an article which does exactly what I want, but on Windows Mobile. (Link: Enable SSL for managed socket on windows mobile)
Quote:
My first surprise was that
SetSocketOption takes a
SocketOptionName enum value as the
second parameter, but this enum
doesn’t have the equivalent of
SO_SECURE. However, C# was nice enough
to let me cast an arbitrary integer
value to the enum I needed.
I tried to do the same, but it doesn't work.
Code:
private const ushort SO_SECURE = 0x2001;
private const ushort SO_SEC_SSL = 0x2004;
this.SetSocketOption(SocketOptionLevel.Socket, (SocketOptionName) SO_SECURE, SO_SEC_SSL);
Error:
An unknown, invalid, or unsupported
option or level was specified in a
getsockopt or setsockopt call
Is there a way to work around this?
Kind regards,
Matthias Vance