Skip to content

Commit d1a069b

Browse files
bagderbch
authored andcommitted
urldata: cease storing TLS auth type
The only TLS auth type libcurl ever supported is SRP and that is the default type. Since nobody ever sets any other type, there is no point in wasting space to store the set type and code to check the type. If TLS auth is used, SRP is now implied. Closes curl#10181
1 parent 61adad4 commit d1a069b

File tree

6 files changed

+12
-48
lines changed

6 files changed

+12
-48
lines changed

lib/setopt.c

+4-23
Original file line numberDiff line numberDiff line change
@@ -2843,52 +2843,33 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
28432843
case CURLOPT_TLSAUTH_USERNAME:
28442844
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME],
28452845
va_arg(param, char *));
2846-
if(data->set.str[STRING_TLSAUTH_USERNAME] &&
2847-
!data->set.ssl.primary.authtype)
2848-
data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
28492846
break;
28502847
#ifndef CURL_DISABLE_PROXY
28512848
case CURLOPT_PROXY_TLSAUTH_USERNAME:
28522849
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY],
28532850
va_arg(param, char *));
2854-
if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2855-
!data->set.proxy_ssl.primary.authtype)
2856-
data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default to
2857-
SRP */
28582851
break;
28592852
#endif
28602853
case CURLOPT_TLSAUTH_PASSWORD:
28612854
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD],
28622855
va_arg(param, char *));
2863-
if(data->set.str[STRING_TLSAUTH_USERNAME] &&
2864-
!data->set.ssl.primary.authtype)
2865-
data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */
28662856
break;
28672857
#ifndef CURL_DISABLE_PROXY
28682858
case CURLOPT_PROXY_TLSAUTH_PASSWORD:
28692859
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY],
28702860
va_arg(param, char *));
2871-
if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
2872-
!data->set.proxy_ssl.primary.authtype)
2873-
data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP; /* default */
28742861
break;
28752862
#endif
28762863
case CURLOPT_TLSAUTH_TYPE:
28772864
argptr = va_arg(param, char *);
2878-
if(!argptr ||
2879-
strncasecompare(argptr, "SRP", strlen("SRP")))
2880-
data->set.ssl.primary.authtype = CURL_TLSAUTH_SRP;
2881-
else
2882-
data->set.ssl.primary.authtype = CURL_TLSAUTH_NONE;
2865+
if(argptr && !strncasecompare(argptr, "SRP", strlen("SRP")))
2866+
return CURLE_BAD_FUNCTION_ARGUMENT;
28832867
break;
28842868
#ifndef CURL_DISABLE_PROXY
28852869
case CURLOPT_PROXY_TLSAUTH_TYPE:
28862870
argptr = va_arg(param, char *);
2887-
if(!argptr ||
2888-
strncasecompare(argptr, "SRP", strlen("SRP")))
2889-
data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_SRP;
2890-
else
2891-
data->set.proxy_ssl.primary.authtype = CURL_TLSAUTH_NONE;
2871+
if(argptr || !strncasecompare(argptr, "SRP", strlen("SRP")))
2872+
return CURLE_BAD_FUNCTION_ARGUMENT;
28922873
break;
28932874
#endif
28942875
#endif

lib/url.c

-3
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,6 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
563563
#endif
564564
set->ssl.primary.verifypeer = TRUE;
565565
set->ssl.primary.verifyhost = TRUE;
566-
#ifdef USE_TLS_SRP
567-
set->ssl.primary.authtype = CURL_TLSAUTH_NONE;
568-
#endif
569566
#ifdef USE_SSH
570567
/* defaults to any auth type */
571568
set->ssh_auth_types = CURLSSH_AUTH_DEFAULT;

lib/urldata.h

-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ struct ssl_primary_config {
283283
#ifdef USE_TLS_SRP
284284
char *username; /* TLS username (for, e.g., SRP) */
285285
char *password; /* TLS password (for, e.g., SRP) */
286-
enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
287286
#endif
288287
char *curves; /* list of curves to use */
289288
unsigned char ssl_options; /* the CURLOPT_SSL_OPTIONS bitmask */

lib/vtls/gtls.c

+7-12
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,10 @@ CURLcode gtls_client_init(struct Curl_easy *data,
434434
}
435435

436436
#ifdef USE_GNUTLS_SRP
437-
if((config->authtype == CURL_TLSAUTH_SRP) &&
438-
Curl_auth_allowed_to_host(data)) {
437+
if(config->username && Curl_auth_allowed_to_host(data)) {
439438
infof(data, "Using TLS-SRP username: %s", config->username);
440439

441-
rc = gnutls_srp_allocate_client_credentials(
442-
&gtls->srp_client_cred);
440+
rc = gnutls_srp_allocate_client_credentials(&gtls->srp_client_cred);
443441
if(rc != GNUTLS_E_SUCCESS) {
444442
failf(data, "gnutls_srp_allocate_client_cred() failed: %s",
445443
gnutls_strerror(rc));
@@ -581,7 +579,7 @@ CURLcode gtls_client_init(struct Curl_easy *data,
581579
#ifdef USE_GNUTLS_SRP
582580
/* Only add SRP to the cipher list if SRP is requested. Otherwise
583581
* GnuTLS will disable TLS 1.3 support. */
584-
if(config->authtype == CURL_TLSAUTH_SRP) {
582+
if(config->username) {
585583
size_t len = strlen(prioritylist);
586584

587585
char *prioritysrp = malloc(len + sizeof(GNUTLS_SRP) + 1);
@@ -646,7 +644,7 @@ CURLcode gtls_client_init(struct Curl_easy *data,
646644

647645
#ifdef USE_GNUTLS_SRP
648646
/* put the credentials to the current session */
649-
if(config->authtype == CURL_TLSAUTH_SRP) {
647+
if(config->username) {
650648
rc = gnutls_credentials_set(gtls->session, GNUTLS_CRD_SRP,
651649
gtls->srp_client_cred);
652650
if(rc != GNUTLS_E_SUCCESS) {
@@ -865,10 +863,8 @@ Curl_gtls_verifyserver(struct Curl_easy *data,
865863
config->verifyhost ||
866864
config->issuercert) {
867865
#ifdef USE_GNUTLS_SRP
868-
if(ssl_config->primary.authtype == CURL_TLSAUTH_SRP
869-
&& ssl_config->primary.username
870-
&& !config->verifypeer
871-
&& gnutls_cipher_get(session)) {
866+
if(ssl_config->primary.username && !config->verifypeer &&
867+
gnutls_cipher_get(session)) {
872868
/* no peer cert, but auth is ok if we have SRP user and cipher and no
873869
peer verify */
874870
}
@@ -1561,8 +1557,7 @@ static int gtls_shutdown(struct Curl_cfilter *cf,
15611557
gnutls_certificate_free_credentials(backend->gtls.cred);
15621558

15631559
#ifdef USE_GNUTLS_SRP
1564-
if(ssl_config->primary.authtype == CURL_TLSAUTH_SRP
1565-
&& ssl_config->primary.username != NULL)
1560+
if(ssl_config->primary.username)
15661561
gnutls_srp_free_client_credentials(backend->gtls.srp_client_cred);
15671562
#endif
15681563

lib/vtls/openssl.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -3469,9 +3469,6 @@ static CURLcode ossl_connect_step1(struct Curl_cfilter *cf,
34693469
#endif
34703470
#endif
34713471
const long int ssl_version = conn_config->version;
3472-
#ifdef USE_OPENSSL_SRP
3473-
const enum CURL_TLSAUTH ssl_authtype = ssl_config->primary.authtype;
3474-
#endif
34753472
char * const ssl_cert = ssl_config->primary.clientcert;
34763473
const struct curl_blob *ssl_cert_blob = ssl_config->primary.cert_blob;
34773474
const char * const ssl_cert_type = ssl_config->cert_type;
@@ -3732,8 +3729,7 @@ static CURLcode ossl_connect_step1(struct Curl_cfilter *cf,
37323729
#endif
37333730

37343731
#ifdef USE_OPENSSL_SRP
3735-
if((ssl_authtype == CURL_TLSAUTH_SRP) &&
3736-
Curl_auth_allowed_to_host(data)) {
3732+
if(ssl_config->primary.username && Curl_auth_allowed_to_host(data)) {
37373733
char * const ssl_username = ssl_config->primary.username;
37383734
char * const ssl_password = ssl_config->primary.password;
37393735
infof(data, "Using TLS-SRP username: %s", ssl_username);

lib/vtls/vtls.c

-4
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ Curl_ssl_config_matches(struct ssl_primary_config *data,
150150
#ifdef USE_TLS_SRP
151151
!Curl_timestrcmp(data->username, needle->username) &&
152152
!Curl_timestrcmp(data->password, needle->password) &&
153-
(data->authtype == needle->authtype) &&
154153
#endif
155154
strcasecompare(data->cipher_list, needle->cipher_list) &&
156155
strcasecompare(data->cipher_list13, needle->cipher_list13) &&
@@ -173,9 +172,6 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
173172
dest->verifystatus = source->verifystatus;
174173
dest->sessionid = source->sessionid;
175174
dest->ssl_options = source->ssl_options;
176-
#ifdef USE_TLS_SRP
177-
dest->authtype = source->authtype;
178-
#endif
179175

180176
CLONE_BLOB(cert_blob);
181177
CLONE_BLOB(ca_info_blob);

0 commit comments

Comments
 (0)