reverted HTTPCLient debug back to defaulted off
Fork of HTTPClient-SSL by
Revision 42:2f464f96c204, committed 2015-02-09
- Comitter:
- Vanger
- Date:
- Mon Feb 09 21:37:04 2015 +0000
- Parent:
- 41:236fa1143e5a
- Child:
- 43:a11d8ee0380b
- Commit message:
- Added back in VERIFY_PEER_FAIL_IF_NO_CERT as an SSLmethod enumeration.; Removed code to allow for null paths in urlParse(); Removed set_time(),CyaSSL_init(), and extra socket_close().; Added check for pointers being NULL before free-ing memory.;
Changed in this revision
HTTPClient.cpp | Show annotated file Show diff for this revision Revisions of this file |
HTTPClient.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/HTTPClient.cpp Fri Jan 23 20:42:31 2015 +0000 +++ b/HTTPClient.cpp Mon Feb 09 21:37:04 2015 +0000 @@ -113,14 +113,10 @@ HTTPClient::HTTPClient() : m_basicAuthUser(NULL), m_basicAuthPassword(NULL), m_httpResponseCode(0) { - set_time(1421106306); + m_sock = &_m_sock; + // CyaSSL_Debugging_ON() ; //Turn on if the CyaSSL library isn't working, turns on debug printf's - CyaSSL_Init(); //Initialize CyaSSL - - m_sock = &_m_sock; - // CyaSSL_Debugging_ON() ; //Turn on if the CyaSSL library isn't working, for debug printf's - - peerMethod = VERIFY_PEER; + peerMethod = VERIFY_NONE; ctx = 0 ; ssl = 0 ; SSLver = 3 ; @@ -132,12 +128,18 @@ HTTPClient::~HTTPClient() { - free((void *)m_basicAuthPassword); - m_basicAuthPassword = NULL; - free((void *)m_basicAuthUser); - m_basicAuthUser = NULL; - free((void *)certificates); - certificates = NULL; + if(m_basicAuthPassword) { + free((void *)m_basicAuthPassword); + m_basicAuthPassword = NULL; + } + if(m_basicAuthUser) { + free((void *)m_basicAuthUser); + m_basicAuthUser = NULL; + } + if(certificates) { + free((void *)certificates); + certificates = NULL; + } } HTTPResult HTTPClient::basicAuth(const char* user, const char* password) //Basic Authentification @@ -244,11 +246,7 @@ } void HTTPClient::setPeerVerification(SSLMethod method) { - if(method != VERIFY_NONE && method != VERIFY_PEER) { - ERR("That is not an acceptable verification choice"); - } else { - peerMethod = method; - } + peerMethod = method; } @@ -700,10 +698,6 @@ } - if(m_sock->is_connected()) { - m_sock->close(); - } - m_sock->close(true); cyassl_free() ; DBG("Completed HTTP transaction"); @@ -882,14 +876,6 @@ *port=0; } char* pathPtr = strchr(hostPtr, '/'); - if(pathPtr == NULL) { - pathPtr = strchr(hostPtr, '#'); - if(pathPtr != NULL) { - pathPtr++; - } else { - pathPtr = (char *)(url + strlen(url)); - } - } if( hostLen == 0 ) { hostLen = pathPtr - hostPtr; @@ -899,8 +885,6 @@ WARN("Host str is too small (%d >= %d)", maxHostLen, hostLen + 1); return HTTP_PARSE; } - memcpy(host, hostPtr, hostLen); - host[hostLen] = '\0'; size_t pathLen; char* fragmentPtr = strchr(hostPtr, '#'); @@ -914,6 +898,8 @@ WARN("Path str is too small (%d >= %d)", maxPathLen, pathLen + 1); return HTTP_PARSE; } + memcpy(host, hostPtr, hostLen); + host[hostLen] = '\0'; memcpy(path, pathPtr, pathLen); path[pathLen] = '\0';
--- a/HTTPClient.h Fri Jan 23 20:42:31 2015 +0000 +++ b/HTTPClient.h Mon Feb 09 21:37:04 2015 +0000 @@ -35,7 +35,8 @@ ///SSL peer verification setting enum SSLMethod { VERIFY_NONE = 0, ///Don't check peer certificate - VERIFY_PEER = 1, ///Check peer certificate and skip if none available (insecure) + VERIFY_PEER = 1, ///Client:Check peer certificate, Server:Check peer certificate and skip if no certificate received + VERIFY_FAIL_IF_NO_PEER_CERT = 2, ///Client:Check peer certificate, Server:Check peer certificate and fail if none found }; ///HTTP client results