Initial commit

FossilOrigin-Name: ff81a462ed50c586bf2f6adcd12e72651d634e45432d920d6ac9b1e6fdbbbb16
This commit is contained in:
7u83@mail.ru 2015-02-09 21:04:14 +00:00
parent 2dd03898b4
commit d86b7cd652
3 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#include "dtls.h"
#include "dtls_gnutls.h"
#include "conn.h"
#include "cw_log.h"
int dtls_gnutls_connect(struct conn *conn)
{
struct dtls_gnutls_data * d;
d = dtls_gnutls_data_create(conn,GNUTLS_CLIENT | GNUTLS_DATAGRAM);
gnutls_handshake_set_timeout(d->session,GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT);
int rc;
do {
rc = gnutls_handshake(d->session);
}while (rc==GNUTLS_E_AGAIN);
if (rc < 0){
cw_log(LOG_ERR,"Can't connect: %s",gnutls_strerror(rc));
return 0;
}
return 1;
}

View File

@ -0,0 +1,8 @@
#include "dtls_gnutls.h"
const char *dtls_gnutls_get_cipher(struct conn *conn)
{
return "Unknown";
}

View File

@ -0,0 +1,26 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "conn.h"
#include "dtls.h"
#include "dtls_gnutls.h"
struct dtls_ssl_cert dtls_gnutls_get_peers_cert(struct conn * conn,unsigned int n)
{
struct dtls_gnutls_data *d;
d=(struct dtls_gnutls_data*)conn->dtls_data;
const gnutls_datum_t * clist;
struct dtls_ssl_cert cert;
unsigned int len;
clist = gnutls_certificate_get_peers(d->session,&len);
cert.size = clist[n].size;
cert.data= clist[n].data;
return cert;
}