SSL *dtls_ssl;
BIO *dtls_bio;
int dtlsver = DTLS1_BAD_VER;
+ int use_psk_neg = 0;
const char *cipher = vpninfo->dtls_cipher;
if (!cipher) {
cipher = "AES256-GCM-SHA384";
#ifndef OPENSSL_NO_PSK
} else if (!strcmp(cipher, "PSK-NEGOTIATE")) {
- dtlsver = 0; /* Let it negotiate */
+ use_psk_neg = 1;
+ dtlsver = DTLS1_2_VERSION;
+ cipher = "PSK";
#endif
#endif
}
if (vpninfo->proto->proto == PROTO_ANYCONNECT) {
/* All the AnyConnect hackery about saved sessions and PSK */
#if defined (HAVE_DTLS12) && !defined(OPENSSL_NO_PSK)
- if (!dtlsver) {
+ if (use_psk_neg) {
SSL_CTX_set_psk_client_callback(vpninfo->dtls_ctx, psk_callback);
/* For PSK we override the DTLS master secret with one derived
* from the HTTPS session. */
return -EINVAL;
}
/* For SSL_CTX_set_cipher_list() */
- cipher = "PSK";
}
#endif /* OPENSSL_NO_PSK */
#ifdef SSL_OP_NO_ENCRYPT_THEN_MAC
* *requires* secure renegotiation support by default. For interop
* with Cisco's resumed DTLS sessions, we have to turn that off.
*/
- if (dtlsver)
+ if (dtlsver && !use_psk_neg)
SSL_CTX_set_options(vpninfo->dtls_ctx, SSL_OP_LEGACY_SERVER_CONNECT);
#endif
#ifdef SSL_OP_NO_EXTENDED_MASTER_SECRET
* So where OpenSSL provides the choice, tell it not to use extms on
* resumed sessions.
*/
- if (dtlsver)
+ if (dtlsver && !use_psk_neg)
SSL_CTX_set_options(vpninfo->dtls_ctx, SSL_OP_NO_EXTENDED_MASTER_SECRET);
#endif
if (!SSL_CTX_set_cipher_list(vpninfo->dtls_ctx, cipher)) {
/* Where they only do DTLSv1, they also don't cope with secure renegotiation */
if (dtlsver == DTLS1_VERSION)
SSL_set_options(dtls_ssl, SSL_OP_LEGACY_SERVER_CONNECT);
- } else if (dtlsver) {
+ } else if (dtlsver && !use_psk_neg) {
/* This is the actual Cisco AnyConnect method, using session resume */
STACK_OF(SSL_CIPHER) *ciphers = SSL_get_ciphers(dtls_ssl);
const SSL_CIPHER *ssl_ciph = NULL;
/* We don't need our own refcount on it any more */
SSL_SESSION_free(dtls_session);
- } else if (vpninfo->dtls_app_id_size > 0) {
+ } else if (use_psk_neg) {
/*
* For ocserv PSK-NEGOTIATE we abuse the session resume
* protocol just to pass an 'App ID' in our ClientHello
* and isn't actually going to be resumed at all.
*/
const uint8_t cs[2] = {0x00, 0x2F}; /* RSA-AES-128 */
- dtls_session = generate_dtls_session(vpninfo, DTLS1_VERSION,
+ dtls_session = generate_dtls_session(vpninfo, dtlsver,
SSL_CIPHER_find(dtls_ssl, cs),
1);
if (!dtls_session) {