C# Secure Sockets (SSL)
Posted
by Matthias Vance
on Stack Overflow
See other posts from Stack Overflow
or by Matthias Vance
Published on 2010-04-21T12:19:29Z
Indexed on
2010/04/21
12:23 UTC
Read the original article
Hit count: 837
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
© Stack Overflow or respective owner