mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
TLS: Now uses SNI
This commit is contained in:
parent
b38fead19f
commit
39f8e7528e
2 changed files with 14 additions and 1 deletions
|
@ -41,8 +41,9 @@ add_library (libshared libshared/src/Color.cpp libshared/src/Color.h
|
||||||
libshared/src/RX.cpp libshared/src/RX.h
|
libshared/src/RX.cpp libshared/src/RX.h
|
||||||
libshared/src/Table.cpp libshared/src/Table.h
|
libshared/src/Table.cpp libshared/src/Table.h
|
||||||
libshared/src/Timer.cpp libshared/src/Timer.h
|
libshared/src/Timer.cpp libshared/src/Timer.h
|
||||||
libshared/src/shared.cpp libshared/src/shared.h
|
|
||||||
libshared/src/format.cpp libshared/src/format.h
|
libshared/src/format.cpp libshared/src/format.h
|
||||||
|
libshared/src/ip.cpp
|
||||||
|
libshared/src/shared.cpp libshared/src/shared.h
|
||||||
libshared/src/unicode.cpp libshared/src/unicode.h
|
libshared/src/unicode.cpp libshared/src/unicode.h
|
||||||
libshared/src/utf8.cpp libshared/src/utf8.h
|
libshared/src/utf8.cpp libshared/src/utf8.h
|
||||||
libshared/src/wcwidth6.cpp)
|
libshared/src/wcwidth6.cpp)
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <gnutls/x509.h>
|
#include <gnutls/x509.h>
|
||||||
|
#include <shared.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
|
|
||||||
#define MAX_BUF 16384
|
#define MAX_BUF 16384
|
||||||
|
@ -210,6 +211,17 @@ void TLSClient::connect (const std::string& host, const std::string& port)
|
||||||
gnutls_session_set_verify_cert (_session, _host.c_str (), 0); // 3.4.6
|
gnutls_session_set_verify_cert (_session, _host.c_str (), 0); // 3.4.6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// SNI. Only permitted when _host is a DNS name, not an IPv4/6 address.
|
||||||
|
std::string dummyAddress;
|
||||||
|
int dummyPort;
|
||||||
|
if (! isIPv4Address (_host, dummyAddress, dummyPort) &&
|
||||||
|
! isIPv6Address (_host, dummyAddress, dummyPort))
|
||||||
|
{
|
||||||
|
ret = gnutls_server_name_set (_session, GNUTLS_NAME_DNS, _host.c_str (), _host.length ()); // All
|
||||||
|
if (ret < 0)
|
||||||
|
throw format ("TLS SNI error. {1}", gnutls_strerror (ret)); // All
|
||||||
|
}
|
||||||
|
|
||||||
// Store the TLSClient instance, so that the verification callback can access
|
// Store the TLSClient instance, so that the verification callback can access
|
||||||
// it during the handshake below and call the verification method.
|
// it during the handshake below and call the verification method.
|
||||||
gnutls_session_set_ptr (_session, (void*) this); // All
|
gnutls_session_set_ptr (_session, (void*) this); // All
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue