开发者

TLS SNI with C#

I am trying to use libcurl.net in my project to do HTTP requests over SSL. (System.Net classes do not support server name extension, and I am using Windows XP)

The code in SSLContextFunction :

public CURLcode OnSSLContext(SSLContext ctx, Object extraData)
{
    IntPtr ssl = SSL_new(ctx.Context);
    SSL_set_tlsext_host_name(ssl, "hostname");
    return CURLcode.CURLE_OK;
}

[DllImport("ssleay32.dll")]
internal static extern IntPtr SSL_new(IntPtr ctx);

[DllImport("ssleay32.dll")]
internal static extern void SSL_set_tlsext_host_name(IntPtr ssl, string message);

This开发者_运维百科 throws an error on the call SSL_new saying : "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Also, tried calling OpenSSL's method SSL_library_init() , but no result.

Thanks


Have you set the CPU platform to match the library you are using? e.g. use x86 if you have an x86 DLL or x64 for an x64 one. (Even if this is not your problem and you only have a 32Bit system, your app will blow on Win64 otherwise)

I haven't used it, but I did find an existing wrapper for libcurl, maybe this can help you: http://sourceforge.net/projects/libcurl-net/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜