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 "cw_log.h"
/*
static BIO_METHOD bio_methods = {
BIO_TYPE_DGRAM,
"cw packet",
@ -15,51 +16,56 @@ static BIO_METHOD bio_methods = {
dtls_openssl_bio_free,
NULL,
};
*/
unsigned int psk_client_cb(SSL * ssl,
const char *hint,
char *identity,
unsigned int max_identity_len,
unsigned char *psk, unsigned int max_psk_len)
{
static unsigned int psk_client_cb(SSL *ssl,
const char *hint,
char *identity,
unsigned int max_identity_len,
unsigned char *psk,
unsigned int max_psk_len) {
BIO *b = SSL_get_rbio(ssl);
struct conn *conn = b->ptr;
BIO * b = SSL_get_rbio(ssl);
struct conn * conn = b->ptr;
// printf("KEYY: %s\n",conn->dtls_psk);
// printf("KEYY: %s\n",conn->dtls_psk);
snprintf(identity, max_identity_len, "CLient_identity");
int l = conn->dtls_psk_len < max_psk_len ? conn->dtls_psk_len : max_psk_len;
memcpy(psk,conn->dtls_psk,l);
memcpy(psk, conn->dtls_psk, l);
return l;
}
int dtls_openssl_connect(struct conn * conn)
int dtls_openssl_connect(struct conn *conn)
{
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)
return 0;
if (conn->dtls_psk)
SSL_set_psk_client_callback( d->ssl, psk_client_cb);
// if (conn->dtls_psk)
// 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];
int rc;
// do{
// char errstr[256];
int rc;
// do{
rc = SSL_connect(d->ssl);
printf("Calling SSL connect\n");
rc = SSL_connect(d->ssl);
printf("Back from SSL connect\n");
exit(0);
/*
if (rc <= 0){
@ -80,27 +86,23 @@ int dtls_openssl_connect(struct conn * conn)
*/
if(rc==1){
conn->read = dtls_openssl_read;
conn->write = dtls_openssl_write;
return 1;
}
if (rc == 1) {
conn->read = dtls_openssl_read;
conn->write = dtls_openssl_write;
return 1;
}
// rc = dtls_openssl_log_error(d->ssl,rc,"DTLS connect");
rc = dtls_openssl_log_error(0, rc, "DTLS connect");
// rc = dtls_openssl_log_error(d->ssl,rc,"DTLS connect");
rc = dtls_openssl_log_error(0,rc,"DTLS connect");
// } while (rc == 0 );
// } while (rc == 0 );
// printf("DTLS connect RC: %i\n",rc);
// printf("DTLS connect RC: %i\n",rc);
// int e = ERR_get_error();
// ERR_error_string(e,errstr);
// cw_log(LOG_ERR,"SSL_accept %s",errstr);
// int e = ERR_get_error();
// ERR_error_string(e,errstr);
// cw_log(LOG_ERR,"SSL_accept %s",errstr);
return 0;
}