OpenSSL em uma DLL do VisualC ++

Estou tentando escrever uma DLL C ++ que usa openSSL para proteger uma conexão com um servidor.

Estou genuinamente intrigado com o fato de esse código

#include "stdafx.h"
#include <string.h>
#include <iostream>
//SSL stuff
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <openssl/ossl_typ.h>
#include <openssl/applink.c>
//Winsock stuf
#pragma comment(lib, "ws2_32.lib")
{... Create a method in which we set up the SSL connection ...}
char* tSend = "{\"reqtype\":\"keyexchange\"}";
int sendSize = strlen(tSend);
int net_tSend = htonl(sendSize);
SSL_write(ssl, &net_tSend, 4);
SSL_write(ssl, tSend, sendSize);

funciona bem em um aplicativo de console, mas trava na minha DLL. Aqui está minha exceção:

Exceção lançada em 0x00007FF865207DA0 (libeay32.dll) em TestsForPKCSDLL.exe: 0xC0000005: local de leitura de violação de acesso 0x0000000000000000.

Muito obrigado pelo seu tempo.

questionAnswers(1)

yourAnswerToTheQuestion