mirror of
https://github.com/Alcaro/Flips.git
synced 2026-09-07 10:06:09 -05:00
Update Arlib
This commit is contained in:
@@ -27,7 +27,7 @@ public:
|
||||
SSL* ssl;
|
||||
//bool nonblock;
|
||||
|
||||
static socketssl_impl* create(socket* parent, const char * domain, bool permissive)
|
||||
static socketssl_impl* create(socket* parent, cstring domain, bool permissive)
|
||||
{
|
||||
if (!parent) return NULL;
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
ret->sock = parent;
|
||||
ret->fd = parent->get_fd();
|
||||
ret->ssl = SSL_new(ctx);
|
||||
SSL_set_tlsext_host_name(ret->ssl, (const char*)domain);
|
||||
//ret->nonblock = false;
|
||||
SSL_set_fd(ret->ssl, ret->fd);
|
||||
//TODO: set fd to nonblock
|
||||
@@ -62,7 +63,7 @@ public:
|
||||
bool ok = (SSL_connect(ret->ssl)==1);
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10002000 // < 1.0.2
|
||||
if (ok && !validate_hostname(domain, SSL_get_peer_certificate(ret->ssl)))
|
||||
if (ok && !permissive && !validate_hostname(domain, SSL_get_peer_certificate(ret->ssl)))
|
||||
{
|
||||
ok=false;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ public:
|
||||
if (!ok)
|
||||
{
|
||||
delete ret;
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -88,14 +89,14 @@ public:
|
||||
}
|
||||
|
||||
//only supports nonblocking
|
||||
int recv(uint8_t* data, unsigned int len, bool block = false)
|
||||
int recv(arrayvieww<uint8_t> data, bool block = false)
|
||||
{
|
||||
return fixret(SSL_read(ssl, data, len));
|
||||
return fixret(SSL_read(ssl, data.ptr(), data.size()));
|
||||
}
|
||||
|
||||
int sendp(const uint8_t* data, unsigned int len, bool block = true)
|
||||
int sendp(arrayview<uint8_t> data, bool block = true)
|
||||
{
|
||||
return fixret(SSL_write(ssl, data, len));
|
||||
return fixret(SSL_write(ssl, data.ptr(), data.size()));
|
||||
}
|
||||
|
||||
~socketssl_impl()
|
||||
@@ -106,7 +107,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
socketssl* socketssl::create(socket* parent, const char * domain, bool permissive)
|
||||
socketssl* socketssl::create(socket* parent, cstring domain, bool permissive)
|
||||
{
|
||||
initialize();
|
||||
if (!ctx) return NULL;
|
||||
|
||||
Reference in New Issue
Block a user