mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
Allow setting DH parameters.
This commit is contained in:
@@ -151,6 +151,7 @@ unsigned j;
|
|||||||
READ_STRING("ocsp-response", config->cert, 0);
|
READ_STRING("ocsp-response", config->cert, 0);
|
||||||
READ_STRING("server-cert", config->cert, 1);
|
READ_STRING("server-cert", config->cert, 1);
|
||||||
READ_STRING("server-key", config->key, 1);
|
READ_STRING("server-key", config->key, 1);
|
||||||
|
READ_STRING("dh-params", config->dh_params_file, 0);
|
||||||
READ_STRING("pin-file", config->pin_file, 0);
|
READ_STRING("pin-file", config->pin_file, 0);
|
||||||
READ_STRING("srk-pin-file", config->srk_pin_file, 0);
|
READ_STRING("srk-pin-file", config->srk_pin_file, 0);
|
||||||
#ifdef ANYCONNECT_CLIENT_COMPAT
|
#ifdef ANYCONNECT_CLIENT_COMPAT
|
||||||
@@ -333,6 +334,7 @@ unsigned i;
|
|||||||
#endif
|
#endif
|
||||||
DEL(config->ocsp_response);
|
DEL(config->ocsp_response);
|
||||||
DEL(config->banner);
|
DEL(config->banner);
|
||||||
|
DEL(config->dh_params_file);
|
||||||
DEL(config->name);
|
DEL(config->name);
|
||||||
DEL(config->cert);
|
DEL(config->cert);
|
||||||
DEL(config->key);
|
DEL(config->key);
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* DO NOT EDIT THIS FILE (ocserv-args.c)
|
* DO NOT EDIT THIS FILE (ocserv-args.c)
|
||||||
*
|
*
|
||||||
* It has been AutoGen-ed March 5, 2013 at 10:09:33 PM by AutoGen 5.16
|
* It has been AutoGen-ed March 7, 2013 at 09:19:14 AM by AutoGen 5.16
|
||||||
* From the definitions ocserv-args.def
|
* From the definitions ocserv-args.def
|
||||||
* and the template file options
|
* and the template file options
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ try-mtu-discovery = false
|
|||||||
server-cert = /path/to/cert.pem
|
server-cert = /path/to/cert.pem
|
||||||
server-key = /path/to/key.pem
|
server-key = /path/to/key.pem
|
||||||
|
|
||||||
|
# Diffie-Hellman parameters. Can be generated using:
|
||||||
|
# certtool --generate-dh-params --outfile /path/to/dh.pem
|
||||||
|
#dh-params = /path/to/dh.pem
|
||||||
|
|
||||||
# If you have a certificate from a CA that provides an OCSP
|
# If you have a certificate from a CA that provides an OCSP
|
||||||
# service you may provide a fresh OCSP status response within
|
# service you may provide a fresh OCSP status response within
|
||||||
# the TLS handshake. That will prevent the client from connecting
|
# the TLS handshake. That will prevent the client from connecting
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* DO NOT EDIT THIS FILE (ocserv-args.h)
|
* DO NOT EDIT THIS FILE (ocserv-args.h)
|
||||||
*
|
*
|
||||||
* It has been AutoGen-ed March 5, 2013 at 10:09:33 PM by AutoGen 5.16
|
* It has been AutoGen-ed March 7, 2013 at 09:19:14 AM by AutoGen 5.16
|
||||||
* From the definitions ocserv-args.def
|
* From the definitions ocserv-args.def
|
||||||
* and the template file options
|
* and the template file options
|
||||||
*
|
*
|
||||||
|
|||||||
+28
-2
@@ -362,7 +362,8 @@ unsigned usage;
|
|||||||
#endif
|
#endif
|
||||||
/* no URL */
|
/* no URL */
|
||||||
ret = gnutls_load_file(s->config->cert, &data);
|
ret = gnutls_load_file(s->config->cert, &data);
|
||||||
GNUTLS_FATAL_ERR(ret);
|
if (ret < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
ret = gnutls_x509_crt_init(&crt);
|
ret = gnutls_x509_crt_init(&crt);
|
||||||
GNUTLS_FATAL_ERR(ret);
|
GNUTLS_FATAL_ERR(ret);
|
||||||
@@ -377,7 +378,9 @@ unsigned usage;
|
|||||||
ret = gnutls_x509_crt_get_key_usage(crt, &usage, NULL);
|
ret = gnutls_x509_crt_get_key_usage(crt, &usage, NULL);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
if (!(usage & GNUTLS_KEY_KEY_ENCIPHERMENT)) {
|
if (!(usage & GNUTLS_KEY_KEY_ENCIPHERMENT)) {
|
||||||
mslog(s, NULL, LOG_WARNING, "server certificate does not support key encipherment; it may cause issues to connecting clients\n");
|
mslog(s, NULL, LOG_WARNING, "server certificate key usage prevents key encipherment; unable to support the RSA ciphersuites\n");
|
||||||
|
if (s->config->dh_params_file != NULL)
|
||||||
|
mslog(s, NULL, LOG_WARNING, "no DH-params file specified; server will be limited to ECDHE ciphersuites\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if GNUTLS_VERSION_NUMBER > 0x030100
|
#if GNUTLS_VERSION_NUMBER > 0x030100
|
||||||
@@ -390,6 +393,27 @@ cleanup:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_dh_params(main_server_st* s, gnutls_certificate_credentials_t cred)
|
||||||
|
{
|
||||||
|
gnutls_datum_t data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (s->config->dh_params_file != NULL) {
|
||||||
|
ret = gnutls_dh_params_init (&s->creds.dh_params);
|
||||||
|
GNUTLS_FATAL_ERR(ret);
|
||||||
|
|
||||||
|
ret = gnutls_load_file(s->config->dh_params_file, &data);
|
||||||
|
GNUTLS_FATAL_ERR(ret);
|
||||||
|
|
||||||
|
ret = gnutls_dh_params_import_pkcs3(s->creds.dh_params, &data, GNUTLS_X509_FMT_PEM);
|
||||||
|
GNUTLS_FATAL_ERR(ret);
|
||||||
|
|
||||||
|
gnutls_free(data.data);
|
||||||
|
|
||||||
|
gnutls_certificate_set_dh_params(cred, s->creds.dh_params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* reload key files etc. */
|
/* reload key files etc. */
|
||||||
void tls_global_init_certs(main_server_st* s)
|
void tls_global_init_certs(main_server_st* s)
|
||||||
{
|
{
|
||||||
@@ -411,6 +435,8 @@ const char* perr;
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_dh_params(s, s->creds.xcred);
|
||||||
|
|
||||||
gnutls_certificate_set_pin_function (s->creds.xcred, pin_callback, &s->creds);
|
gnutls_certificate_set_pin_function (s->creds.xcred, pin_callback, &s->creds);
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ void tls_fatal_close(gnutls_session_t session,
|
|||||||
struct tls_st {
|
struct tls_st {
|
||||||
gnutls_certificate_credentials_t xcred;
|
gnutls_certificate_credentials_t xcred;
|
||||||
gnutls_priority_t cprio;
|
gnutls_priority_t cprio;
|
||||||
|
gnutls_dh_params_t dh_params;
|
||||||
char pin[MAX_PIN_SIZE];
|
char pin[MAX_PIN_SIZE];
|
||||||
char srk_pin[MAX_PIN_SIZE];
|
char srk_pin[MAX_PIN_SIZE];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ struct cfg_st {
|
|||||||
char *key;
|
char *key;
|
||||||
char *ca;
|
char *ca;
|
||||||
char *crl;
|
char *crl;
|
||||||
|
char *dh_params_file;
|
||||||
char *cert_user_oid; /* The OID that will be used to extract the username */
|
char *cert_user_oid; /* The OID that will be used to extract the username */
|
||||||
char *cert_group_oid; /* The OID that will be used to extract the groupname */
|
char *cert_group_oid; /* The OID that will be used to extract the groupname */
|
||||||
unsigned int auth_types; /* or'ed sequence of AUTH_TYPE */
|
unsigned int auth_types; /* or'ed sequence of AUTH_TYPE */
|
||||||
|
|||||||
Reference in New Issue
Block a user