Uses dtls_openssl_bio_bethod to get bio method.

FossilOrigin-Name: 6182de5df5425da3a79fb04de245fd4e5213b914ce61a606e1fb3b4a15e74a5f
This commit is contained in:
7u83@mail.ru 2015-02-02 23:27:58 +00:00
parent 5008b12d8e
commit b57e4c69c7
1 changed files with 40 additions and 38 deletions

View File

@ -3,6 +3,7 @@
#include "dtls_openssl.h" #include "dtls_openssl.h"
#include "cw_log.h" #include "cw_log.h"
/*
static BIO_METHOD bio_methods = { static BIO_METHOD bio_methods = {
BIO_TYPE_DGRAM, BIO_TYPE_DGRAM,
"cw packet", "cw packet",
@ -15,14 +16,14 @@ static BIO_METHOD bio_methods = {
dtls_openssl_bio_free, dtls_openssl_bio_free,
NULL, NULL,
}; };
*/
unsigned int psk_client_cb(SSL * ssl,
static unsigned int psk_client_cb(SSL *ssl,
const char *hint, const char *hint,
char *identity, char *identity,
unsigned int max_identity_len, unsigned int max_identity_len,
unsigned char *psk, unsigned char *psk, unsigned int max_psk_len)
unsigned int max_psk_len) { {
BIO *b = SSL_get_rbio(ssl); BIO *b = SSL_get_rbio(ssl);
struct conn *conn = b->ptr; struct conn *conn = b->ptr;
@ -41,25 +42,30 @@ static unsigned int psk_client_cb(SSL *ssl,
int dtls_openssl_connect(struct conn *conn) int dtls_openssl_connect(struct conn *conn)
{ {
if (!conn->dtls_data) if (!conn->dtls_data)
conn->dtls_data = dtls_openssl_data_create(conn,DTLSv1_client_method(),&bio_methods); conn->dtls_data =
dtls_openssl_data_create(conn, DTLSv1_client_method(),
dtls_openssl_bio_method());
struct dtls_openssl_data *d = (struct dtls_openssl_data *) conn->dtls_data; struct dtls_openssl_data *d = (struct dtls_openssl_data *) conn->dtls_data;
if (!d) if (!d)
return 0; return 0;
if (conn->dtls_psk) // if (conn->dtls_psk)
SSL_set_psk_client_callback( d->ssl, psk_client_cb); // SSL_set_psk_client_callback(d->ssl, psk_client_cb);
// dtls_openssl_set_certs(conn,d); // dtls_openssl_set_certs(conn,d);
if (conn->dtls_cert_file && conn->dtls_key_file) { if (conn->dtls_cert_file && conn->dtls_key_file) {
} }
// char errstr[256]; // char errstr[256];
int rc; int rc;
// do{ // do{
printf("Calling SSL connect\n");
rc = SSL_connect(d->ssl); rc = SSL_connect(d->ssl);
printf("Back from SSL connect\n");
exit(0);
/* /*
if (rc <= 0){ if (rc <= 0){
@ -86,7 +92,6 @@ int dtls_openssl_connect(struct conn * conn)
return 1; return 1;
} }
// rc = dtls_openssl_log_error(d->ssl,rc,"DTLS connect"); // rc = dtls_openssl_log_error(d->ssl,rc,"DTLS connect");
rc = dtls_openssl_log_error(0, rc, "DTLS connect"); rc = dtls_openssl_log_error(0, rc, "DTLS connect");
@ -101,6 +106,3 @@ int dtls_openssl_connect(struct conn * conn)
return 0; return 0;
} }