summaryrefslogtreecommitdiff
path: root/lib/stream-ssl.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-01-25 15:17:32 -0800
committerBen Pfaff <blp@nicira.com>2011-01-25 17:10:48 -0800
commitb5beaca19879c2b662fdb136262c81bf22f747da (patch)
treee2a39dc74643156dae864a3f1deb31d75961be6d /lib/stream-ssl.c
parent36f0987fc984fff0893c5929161acd50871b2987 (diff)
downloadopenvswitch-b5beaca19879c2b662fdb136262c81bf22f747da.tar.gz
stream-ssl: Set a session context ID string on our SSL_CTX.
In the finest OpenSSL tradition of putting important documentation only in code comments, ssl/ssl_sess.c in the OpenSSL tree has the following comment inside ssl_get_prev_session(): /* We can't be sure if this session is being used out of * context, which is especially important for SSL_VERIFY_PEER. * The application should have used SSL[_CTX]_set_session_id_context. * * For this error case, we generate an error instead of treating * the event like a cache miss (otherwise it would be easy for * applications to effectively disable the session cache by * accident without anyone noticing). */ This meant that ovs-controller couldn't effectively cache SSL server sessions and we got a weird error whenever ovs-vswitchd tried. Bug #4448. CC: David Tsai <dtsai@nicira.com> CC: Jeremy Stribling <strib@nicira.com>
Diffstat (limited to 'lib/stream-ssl.c')
-rw-r--r--lib/stream-ssl.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c
index 6baf88ff1..ca3d218bf 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -1011,6 +1011,17 @@ do_ssl_init(void)
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
NULL);
+ /* We have to set a session context ID string in 'ctx' because OpenSSL
+ * otherwise refuses to use a cached session on the server side when
+ * SSL_VERIFY_PEER is set. And it not only refuses to use the cached
+ * session, it actually generates an error and kills the connection.
+ * According to a comment in ssl_get_prev_session() in OpenSSL's
+ * ssl/ssl_sess.c, this is intentional behavior.
+ *
+ * Any context string is OK, as long as one is set. */
+ SSL_CTX_set_session_id_context(ctx, (const unsigned char *) PACKAGE,
+ strlen(PACKAGE));
+
return 0;
}