mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TLSClient: Improved C+ Core Guidelines compliance
This commit is contained in:
parent
688d6b658b
commit
08bbf9aa20
1 changed files with 13 additions and 13 deletions
|
@ -186,7 +186,7 @@ void TLSClient::init (
|
|||
if (ret < 0)
|
||||
{
|
||||
if (_debug && ret == GNUTLS_E_INVALID_REQUEST)
|
||||
std::cout << "c: ERROR Priority error at: " << err << "\n";
|
||||
std::cout << "c: ERROR Priority error at: " << err << '\n';
|
||||
|
||||
throw format (STRING_TLS_INIT_FAIL, gnutls_strerror (ret));
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ void TLSClient::connect (const std::string& host, const std::string& port)
|
|||
{
|
||||
#if GNUTLS_VERSION_NUMBER >= 0x03010a
|
||||
char* desc = gnutls_session_get_desc (_session);
|
||||
std::cout << "c: INFO Handshake was completed: " << desc << "\n";
|
||||
std::cout << "c: INFO Handshake was completed: " << desc << '\n';
|
||||
gnutls_free (desc);
|
||||
#else
|
||||
std::cout << "c: INFO Handshake was completed.\n";
|
||||
|
@ -315,7 +315,7 @@ int TLSClient::verify_certificate () const
|
|||
if (ret < 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: ERROR Certificate verification peers3 failed. " << gnutls_strerror (ret) << "\n";
|
||||
std::cout << "c: ERROR Certificate verification peers3 failed. " << gnutls_strerror (ret) << '\n';
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -325,18 +325,18 @@ int TLSClient::verify_certificate () const
|
|||
// GNUTLS_CERT_UNEXPECTED_OWNER 1<<14 Hostname does not match
|
||||
|
||||
if (_debug && status)
|
||||
std::cout << "c: ERROR Certificate status=" << status << "\n";
|
||||
std::cout << "c: ERROR Certificate status=" << status << '\n';
|
||||
#else
|
||||
int ret = gnutls_certificate_verify_peers2 (_session, &status);
|
||||
if (ret < 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: ERROR Certificate verification peers2 failed. " << gnutls_strerror (ret) << "\n";
|
||||
std::cout << "c: ERROR Certificate verification peers2 failed. " << gnutls_strerror (ret) << '\n';
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
||||
if (_debug && status)
|
||||
std::cout << "c: ERROR Certificate status=" << status << "\n";
|
||||
std::cout << "c: ERROR Certificate status=" << status << '\n';
|
||||
|
||||
if ((status == 0) && (_trust != TLSClient::ignore_hostname))
|
||||
{
|
||||
|
@ -350,7 +350,7 @@ int TLSClient::verify_certificate () const
|
|||
if (cert_list_size == 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: ERROR Certificate get peers failed. " << gnutls_strerror (ret) << "\n";
|
||||
std::cout << "c: ERROR Certificate get peers failed. " << gnutls_strerror (ret) << '\n';
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ int TLSClient::verify_certificate () const
|
|||
if (ret < 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: ERROR x509 init failed. " << gnutls_strerror (ret) << "\n";
|
||||
std::cout << "c: ERROR x509 init failed. " << gnutls_strerror (ret) << '\n';
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ int TLSClient::verify_certificate () const
|
|||
if (ret < 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: ERROR x509 cert import. " << gnutls_strerror (ret) << "\n";
|
||||
std::cout << "c: ERROR x509 cert import. " << gnutls_strerror (ret) << '\n';
|
||||
gnutls_x509_crt_deinit(cert);
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ int TLSClient::verify_certificate () const
|
|||
if (gnutls_x509_crt_check_hostname (cert, hostname) == 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: ERROR x509 cert check hostname. " << gnutls_strerror (ret) << "\n";
|
||||
std::cout << "c: ERROR x509 cert check hostname. " << gnutls_strerror (ret) << '\n';
|
||||
gnutls_x509_crt_deinit(cert);
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
@ -391,12 +391,12 @@ int TLSClient::verify_certificate () const
|
|||
if (ret < 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: ERROR certificate verification status. " << gnutls_strerror (ret) << "\n";
|
||||
std::cout << "c: ERROR certificate verification status. " << gnutls_strerror (ret) << '\n';
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
||||
if (_debug)
|
||||
std::cout << "c: INFO " << out.data << "\n";
|
||||
std::cout << "c: INFO " << out.data << '\n';
|
||||
gnutls_free (out.data);
|
||||
#endif
|
||||
|
||||
|
@ -502,7 +502,7 @@ void TLSClient::recv (std::string& data)
|
|||
if (received < 0 && gnutls_error_is_fatal (received) == 0)
|
||||
{
|
||||
if (_debug)
|
||||
std::cout << "c: WARNING " << gnutls_strerror (received) << "\n";
|
||||
std::cout << "c: WARNING " << gnutls_strerror (received) << '\n';
|
||||
}
|
||||
else if (received < 0)
|
||||
throw std::string (gnutls_strerror (received));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue