Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No TLS 1.3 with SNI when default context without certificate #154

Open
Zash opened this issue Feb 9, 2020 · 1 comment
Open

No TLS 1.3 with SNI when default context without certificate #154

Zash opened this issue Feb 9, 2020 · 1 comment

Comments

@Zash
Copy link
Contributor

Zash commented Feb 9, 2020

In a setup where certificates are selected via SNI and the default context has no certificate, connections are capped to TLS 1.2, despite TLS 1.3 being available.

Setting a default certificate and results in TLS 1.3.

To reproduce, apply the following patch to the sni sample and run

lua server.lua &
openssl s_client -connect 127.0.0.1:8888 -servername servera.br
diff --git a/samples/sni/server.lua b/samples/sni/server.lua
index 2de6a8d..ae5f6ed 100644
--- a/samples/sni/server.lua
+++ b/samples/sni/server.lua
@@ -1,6 +1,13 @@
 local socket = require("socket")
 local ssl    = require("ssl")
 
+local params00 = {
+  mode = "server",
+  protocol = "any",
+  cafile = "../certs/rootA.pem",
+  verify = "none",
+}
+
 local params01 = {
   mode = "server",
   protocol = "any",
@@ -24,6 +31,7 @@ local params02 = {
 }
 
 --
+local ctx00 = ssl.newcontext(params00)
 local ctx01 = ssl.newcontext(params01)
 local ctx02 = ssl.newcontext(params02)
 
@@ -36,7 +44,7 @@ local conn = server:accept()
 --
 
 -- Default context (when client does not send a name) is ctx01
-conn = ssl.wrap(conn, ctx01)
+conn = ssl.wrap(conn, ctx00)
 
 -- Configure the name map
 local sni_map = {
@brunoos
Copy link
Member

brunoos commented Feb 18, 2020

I did the same example in Python to see what happens and I got the same result.

It seems that TLS 1.3 needs certificate/key in the earlier stage of handshake, before SNI. Since it does not have them, it downgrades to TLS 1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants