Skip to content

Commit fd76bfe

Browse files
committed
Force TSL v1.0 and allow cipher suite configuration
1 parent 495a590 commit fd76bfe

File tree

4 files changed

+48
-13
lines changed

4 files changed

+48
-13
lines changed

src/conf.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ typedef enum {
100100
oProxyPort,
101101
oSSLPeerVerification,
102102
oSSLCertPath,
103+
oSSLAllowedCipherList,
103104
} OpCodes;
104105

105106
/** @internal
@@ -142,6 +143,7 @@ static const struct {
142143
{ "proxyport", oProxyPort },
143144
{ "sslpeerverification", oSSLPeerVerification },
144145
{ "sslcertpath", oSSLCertPath },
146+
{ "sslallowedcipherlist", oSSLAllowedCipherList },
145147
{ NULL, oBadOption },
146148
};
147149

@@ -193,6 +195,7 @@ config_init(void)
193195
config.proxy_port = 0;
194196
config.ssl_certs = safe_strdup(DEFAULT_AUTHSERVSSLCERTPATH);
195197
config.ssl_verify = DEFAULT_AUTHSERVSSLPEERVER;
198+
config.ssl_cipher_list = NULL;
196199
}
197200

198201
/**
@@ -738,13 +741,6 @@ config_read(const char *filename)
738741
case oHTTPDPassword:
739742
config.httpdpassword = safe_strdup(p1);
740743
break;
741-
case oBadOption:
742-
debug(LOG_ERR, "Bad option on line %d "
743-
"in %s.", linenum,
744-
filename);
745-
debug(LOG_ERR, "Exiting...");
746-
exit(-1);
747-
break;
748744
case oCheckInterval:
749745
sscanf(p1, "%d", &config.checkinterval);
750746
break;
@@ -778,6 +774,21 @@ config_read(const char *filename)
778774
debug(LOG_WARNING, "SSLPeerVerification is set but no SSL compiled in. Ignoring!");
779775
#endif
780776
break;
777+
case oSSLAllowedCipherList:
778+
config.ssl_cipher_list = safe_strdup(p1);
779+
#ifndef USE_CYASSL
780+
debug(LOG_WARNING, "SSLAllowedCipherList is set but no SSL compiled in. Ignoring!");
781+
#endif
782+
break;
783+
case oBadOption:
784+
/* FALL THROUGH */
785+
default:
786+
debug(LOG_ERR, "Bad option on line %d "
787+
"in %s.", linenum,
788+
filename);
789+
debug(LOG_ERR, "Exiting...");
790+
exit(-1);
791+
break;
781792
}
782793
}
783794
}

src/conf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ typedef struct {
171171
verification */
172172
int ssl_verify; /**< @brief boolean, whether to enable
173173
auth server certificate verification */
174+
char *ssl_cipher_list; /**< @brief List of SSL ciphers allowed. Optional. */
174175
t_firewall_ruleset *rulesets; /**< @brief firewall rules */
175176
t_trusted_mac *trustedmaclist; /**< @brief list of trusted macs */
176177
} s_config;

src/simple_http.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static pthread_mutex_t cyassl_ctx_mutex = PTHREAD_MUTEX_INITIALIZER;
144144
static CYASSL_CTX *
145145
get_cyassl_ctx(void)
146146
{
147+
int err;
147148
CYASSL_CTX *ret;
148149
s_config *config = config_get_config();
149150

@@ -152,16 +153,26 @@ get_cyassl_ctx(void)
152153
if (NULL == cyassl_ctx) {
153154
CyaSSL_Init();
154155
/* Create the CYASSL_CTX */
155-
/* Allow SSLv3 up to TLSv1.2 */
156-
if ( (cyassl_ctx = CyaSSL_CTX_new(CyaSSLv23_client_method())) == NULL){
156+
/* Allow TLSv1.0 up to TLSv1.2 */
157+
if ( (cyassl_ctx = CyaSSL_CTX_new(CyaTLSv1_client_method())) == NULL){
157158
debug(LOG_ERR, "Could not create CYASSL context.");
158159
return NULL;
159160
}
160161

162+
if (config->ssl_cipher_list) {
163+
debug(LOG_INFO, "Setting SSL cipher list to [%s]", config->ssl_cipher_list);
164+
err = CyaSSL_CTX_set_cipher_list(cyassl_ctx, config->ssl_cipher_list);
165+
if (SSL_SUCCESS != err) {
166+
debug(LOG_ERR, "Could not load SSL cipher list (error %d)", err);
167+
return NULL;
168+
}
169+
}
170+
161171
if (config->ssl_verify) {
162172
/* Use trusted certs */
163173
/* Note: CyaSSL requires that the certificates are named by their hash values */
164-
int err = CyaSSL_CTX_load_verify_locations(cyassl_ctx, NULL, config->ssl_certs);
174+
debug(LOG_INFO, "Loading SSL certificates from %s", config->ssl_certs);
175+
err = CyaSSL_CTX_load_verify_locations(cyassl_ctx, NULL, config->ssl_certs);
165176
if (err != SSL_SUCCESS) {
166177
debug(LOG_ERR, "Could not load SSL certificates (error %d)", err);
167178
if (err == ASN_UNKNOWN_OID_E) {
@@ -170,9 +181,8 @@ get_cyassl_ctx(void)
170181
debug(LOG_ERR, "Make sure that SSLCertPath points to the correct path in the config file");
171182
debug(LOG_ERR, "Or disable certificate loading with 'SSLPeerVerification No'.");
172183
}
173-
return NULL;;
184+
return NULL;
174185
}
175-
debug(LOG_INFO, "Loading SSL certificates from %s", config->ssl_certs);
176186
} else {
177187
CyaSSL_CTX_set_verify(cyassl_ctx, SSL_VERIFY_NONE, 0);
178188
debug(LOG_INFO, "Disabling SSL certificate verification!");

wifidog.conf

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ ClientTimeout 5
185185
#
186186
# SSLPeerVerification Yes
187187

188-
189188
# Parameter: SSLCertPath
190189
# Default: /etc/ssl/certs/
191190
# Optional
@@ -204,6 +203,20 @@ ClientTimeout 5
204203
#
205204
# SSLCertPath /etc/ssl/certs/
206205

206+
# Parameter: SSLAllowedCipherList
207+
# Default: all ciphers supported
208+
# Optional
209+
#
210+
# Which cipher suite to allow. Note that CyaSSL will ignore cipher
211+
# suites that use algorithms that aren't compiled in or cipher
212+
# suites *WITH ERRORS IN THEIR NAMES*.
213+
#
214+
# Please see CyaSSL documentation for allowed values, format is a
215+
# string where the ciphers are separated by colons (:) with no
216+
# spaces. Ciphers are ordered from most desirable to least desirable.
217+
#
218+
# SSLAllowedCipherList ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:ECDH-ECDSA-AES128-GCM-SHA256:ECDH-ECDSA-AES256-GCM-SHA384:ECDH-RSA-AES128-GCM-SHA256:ECDH-RSA-AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:ECDH-ECDSA-AES128-SHA:ECDH-ECDSA-AES256-SHA:ECDH-RSA-AES128-SHA:ECDH-RSA-AES256-SHA:AES128-SHA:AES256-SHA
219+
207220
# Parameter: TrustedMACList
208221
# Default: none
209222
# Optional

0 commit comments

Comments
 (0)