axtls.c: cleanup
Removed trailing whitespace Removed several compiler warnings Removed odd backslashes at some line endings
This commit is contained in:
parent
b998b04c02
commit
b88ead62e7
76
lib/axtls.c
76
lib/axtls.c
@ -182,13 +182,13 @@ Curl_axtls_connect(struct connectdata *conn,
|
||||
|
||||
/* Load the trusted CA cert bundle file */
|
||||
if(data->set.ssl.CAfile) {
|
||||
if(ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, data->set.ssl.CAfile, NULL) \
|
||||
if(ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT, data->set.ssl.CAfile, NULL)
|
||||
!= SSL_OK){
|
||||
infof(data, "error reading ca cert file %s \n",
|
||||
data->set.ssl.CAfile);
|
||||
data->set.ssl.CAfile);
|
||||
if(data->set.ssl.verifypeer){
|
||||
Curl_axtls_close(conn, sockindex);
|
||||
return CURLE_SSL_CACERT_BADFILE;
|
||||
Curl_axtls_close(conn, sockindex);
|
||||
return CURLE_SSL_CACERT_BADFILE;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -208,19 +208,19 @@ Curl_axtls_connect(struct connectdata *conn,
|
||||
i=0;
|
||||
/* Instead of trying to analyze cert type here, let axTLS try them all. */
|
||||
while(cert_types[i] != 0){
|
||||
ssl_fcn_return = ssl_obj_load(ssl_ctx, cert_types[i], \
|
||||
data->set.str[STRING_CERT], NULL);
|
||||
ssl_fcn_return = ssl_obj_load(ssl_ctx, cert_types[i],
|
||||
data->set.str[STRING_CERT], NULL);
|
||||
if(ssl_fcn_return == SSL_OK){
|
||||
infof(data, "successfully read cert file %s \n", \
|
||||
data->set.str[STRING_CERT]);
|
||||
break;
|
||||
infof(data, "successfully read cert file %s \n",
|
||||
data->set.str[STRING_CERT]);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/* Tried all cert types, none worked. */
|
||||
if(cert_types[i] == 0){
|
||||
failf(data, "%s is not x509 or pkcs12 format", \
|
||||
data->set.str[STRING_CERT]);
|
||||
failf(data, "%s is not x509 or pkcs12 format",
|
||||
data->set.str[STRING_CERT]);
|
||||
Curl_axtls_close(conn, sockindex);
|
||||
return CURLE_SSL_CERTPROBLEM;
|
||||
}
|
||||
@ -233,19 +233,19 @@ Curl_axtls_connect(struct connectdata *conn,
|
||||
i=0;
|
||||
/* Instead of trying to analyze key type here, let axTLS try them all. */
|
||||
while(key_types[i] != 0){
|
||||
ssl_fcn_return = ssl_obj_load(ssl_ctx, key_types[i], \
|
||||
data->set.str[STRING_KEY], NULL);
|
||||
ssl_fcn_return = ssl_obj_load(ssl_ctx, key_types[i],
|
||||
data->set.str[STRING_KEY], NULL);
|
||||
if(ssl_fcn_return == SSL_OK){
|
||||
infof(data, "successfully read key file %s \n", \
|
||||
data->set.str[STRING_KEY]);
|
||||
break;
|
||||
infof(data, "successfully read key file %s \n",
|
||||
data->set.str[STRING_KEY]);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/* Tried all key types, none worked. */
|
||||
if(key_types[i] == 0){
|
||||
failf(data, "Failure: %s is not a supported key file", \
|
||||
data->set.str[STRING_KEY]);
|
||||
failf(data, "Failure: %s is not a supported key file",
|
||||
data->set.str[STRING_KEY]);
|
||||
Curl_axtls_close(conn, sockindex);
|
||||
return CURLE_SSL_CONNECT_ERROR;
|
||||
}
|
||||
@ -258,11 +258,11 @@ Curl_axtls_connect(struct connectdata *conn,
|
||||
*/
|
||||
|
||||
/* In axTLS, handshaking happens inside ssl_client_new. */
|
||||
if(!Curl_ssl_getsessionid(conn, (void **) &ssl_sessionid, &ssl_idsize)){
|
||||
if(!Curl_ssl_getsessionid(conn, (void **) &ssl_sessionid, &ssl_idsize)) {
|
||||
/* we got a session id, use it! */
|
||||
infof (data, "SSL re-using session ID\n");
|
||||
ssl = ssl_client_new(ssl_ctx, conn->sock[sockindex], \
|
||||
ssl_sessionid, ssl_idsize);
|
||||
ssl = ssl_client_new(ssl_ctx, conn->sock[sockindex],
|
||||
ssl_sessionid, (uint8_t)ssl_idsize);
|
||||
}
|
||||
else
|
||||
ssl = ssl_client_new(ssl_ctx, conn->sock[sockindex], NULL, 0);
|
||||
@ -317,7 +317,7 @@ Curl_axtls_connect(struct connectdata *conn,
|
||||
/* Put our freshly minted SSL session in cache */
|
||||
ssl_idsize = ssl_get_session_id_size(ssl);
|
||||
ssl_sessionid = ssl_get_session_id(ssl);
|
||||
if(Curl_ssl_addsessionid(conn, (void *) ssl_sessionid, ssl_idsize) \
|
||||
if(Curl_ssl_addsessionid(conn, (void *) ssl_sessionid, ssl_idsize)
|
||||
!= CURLE_OK)
|
||||
infof (data, "failed to add session to cache\n");
|
||||
|
||||
@ -327,15 +327,12 @@ Curl_axtls_connect(struct connectdata *conn,
|
||||
|
||||
/* return number of sent (non-SSL) bytes */
|
||||
static ssize_t axtls_send(struct connectdata *conn,
|
||||
int sockindex,
|
||||
const void *mem,
|
||||
size_t len,
|
||||
CURLcode *err)
|
||||
int sockindex,
|
||||
const void *mem,
|
||||
size_t len,
|
||||
CURLcode *err)
|
||||
{
|
||||
/* ssl_write() returns 'int' while write() and send() returns
|
||||
'size_t' */
|
||||
char error_buffer[120]; /* Comply with OpenSSL, which documents that this
|
||||
must be at least 120 bytes long. */
|
||||
/* ssl_write() returns 'int' while write() and send() returns 'size_t' */
|
||||
int rc = ssl_write(conn->ssl[sockindex].ssl, mem, (int)len);
|
||||
|
||||
infof(conn->data, " axtls_send\n");
|
||||
@ -407,16 +404,16 @@ int Curl_axtls_shutdown(struct connectdata *conn, int sockindex)
|
||||
|
||||
if(connssl->ssl) {
|
||||
int what = Curl_socket_ready(conn->sock[sockindex],
|
||||
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
||||
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
||||
if(what > 0) {
|
||||
/* Something to read, let's do it and hope that it is the close
|
||||
notify alert from the server */
|
||||
notify alert from the server */
|
||||
nread = (ssize_t)SSL_read(conn->ssl[sockindex].ssl, buf,
|
||||
sizeof(buf));
|
||||
sizeof(buf));
|
||||
|
||||
if (nread < SSL_OK){
|
||||
failf(data, "close notify alert not received during shutdown");
|
||||
retval = -1;
|
||||
failf(data, "close notify alert not received during shutdown");
|
||||
retval = -1;
|
||||
}
|
||||
}
|
||||
else if(0 == what) {
|
||||
@ -436,10 +433,10 @@ int Curl_axtls_shutdown(struct connectdata *conn, int sockindex)
|
||||
}
|
||||
|
||||
static ssize_t axtls_recv(struct connectdata *conn, /* connection data */
|
||||
int num, /* socketindex */
|
||||
char *buf, /* store read data here */
|
||||
size_t buffersize, /* max amount to read */
|
||||
CURLcode *err)
|
||||
int num, /* socketindex */
|
||||
char *buf, /* store read data here */
|
||||
size_t buffersize, /* max amount to read */
|
||||
CURLcode *err)
|
||||
{
|
||||
struct ssl_connect_data *connssl = &conn->ssl[num];
|
||||
ssize_t ret = 0;
|
||||
@ -484,6 +481,7 @@ int Curl_axtls_check_cxn(struct connectdata *conn)
|
||||
|
||||
void Curl_axtls_session_free(void *ptr)
|
||||
{
|
||||
(void)ptr;
|
||||
/* free the ID */
|
||||
/* both ssluse.c and gtls.c do something here, but axTLS's OpenSSL
|
||||
compatibility layer does nothing, so we do nothing too. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user