Annotate

net/http/codes.lua @ 13801:a5d5fefb8b68 13.0

mod_tls: Enable Prosody's certificate checking for incoming s2s connections (fixes #1916) (thanks Damian, Zash) Various options in Prosody allow control over the behaviour of the certificate verification process For example, some deployments choose to allow falling back to traditional "dialback" authentication (XEP-0220), while others verify via DANE, hard-coded fingerprints, or other custom plugins. Implementing this flexibility requires us to override OpenSSL's default certificate verification, to allow Prosody to verify the certificate itself, apply custom policies and make decisions based on the outcome. To enable our custom logic, we have to suppress OpenSSL's default behaviour of aborting the connection with a TLS alert message. With LuaSec, this can be achieved by using the verifyext "lsec_continue" flag. We also need to use the lsec_ignore_purpose flag, because XMPP s2s uses server certificates as "client" certificates (for mutual TLS verification in outgoing s2s connections). Commit 99d2100d2918 moved these settings out of the defaults and into mod_s2s, because we only really need these changes for s2s, and they should be opt-in, rather than automatically applied to all TLS services we offer. That commit was incomplete, because it only added the flags for incoming direct TLS connections. StartTLS connections are handled by mod_tls, which was not applying the lsec_* flags. It previously worked because they were already in the defaults. This resulted in incoming s2s connections with "invalid" certificates being aborted early by OpenSSL, even if settings such as `s2s_secure_auth = false` or DANE were present in the config. Outgoing s2s connections inherit verify "none" from the defaults, which means OpenSSL will receive the cert but will not terminate the connection when it is deemed invalid. This means we don't need lsec_continue there, and we also don't need lsec_ignore_purpose (because the remote peer is a "server"). Wondering why we can't just use verify "none" for incoming s2s? It's because in that mode, OpenSSL won't request a certificate from the peer for incoming connections. Setting verify "peer" is how you ask OpenSSL to request a certificate from the client, but also what triggers its built-in verification.
author Matthew Wild <mwild1@gmail.com>
date Tue, 01 Apr 2025 17:26:56 +0100
parent 12548:5133d6e48686
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local response_codes = {
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 -- Source: http://www.iana.org/assignments/http-status-codes
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
4
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
5 [100] = "Continue"; -- RFC9110, Section 15.2.1
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
6 [101] = "Switching Protocols"; -- RFC9110, Section 15.2.2
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7 [102] = "Processing";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
8 [103] = "Early Hints";
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
9 -- [104-199] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
11 [200] = "OK"; -- RFC9110, Section 15.3.1
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
12 [201] = "Created"; -- RFC9110, Section 15.3.2
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
13 [202] = "Accepted"; -- RFC9110, Section 15.3.3
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
14 [203] = "Non-Authoritative Information"; -- RFC9110, Section 15.3.4
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
15 [204] = "No Content"; -- RFC9110, Section 15.3.5
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
16 [205] = "Reset Content"; -- RFC9110, Section 15.3.6
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
17 [206] = "Partial Content"; -- RFC9110, Section 15.3.7
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 [207] = "Multi-Status";
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 [208] = "Already Reported";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
20 -- [209-225] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21 [226] = "IM Used";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
22 -- [227-299] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
24 [300] = "Multiple Choices"; -- RFC9110, Section 15.4.1
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
25 [301] = "Moved Permanently"; -- RFC9110, Section 15.4.2
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
26 [302] = "Found"; -- RFC9110, Section 15.4.3
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
27 [303] = "See Other"; -- RFC9110, Section 15.4.4
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
28 [304] = "Not Modified"; -- RFC9110, Section 15.4.5
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
29 [305] = "Use Proxy"; -- RFC9110, Section 15.4.6
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
30 -- [306] = "(Unused)"; -- RFC9110, Section 15.4.7
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
31 [307] = "Temporary Redirect"; -- RFC9110, Section 15.4.8
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
32 [308] = "Permanent Redirect"; -- RFC9110, Section 15.4.9
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
33 -- [309-399] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
34
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
35 [400] = "Bad Request"; -- RFC9110, Section 15.5.1
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
36 [401] = "Unauthorized"; -- RFC9110, Section 15.5.2
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
37 [402] = "Payment Required"; -- RFC9110, Section 15.5.3
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
38 [403] = "Forbidden"; -- RFC9110, Section 15.5.4
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
39 [404] = "Not Found"; -- RFC9110, Section 15.5.5
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
40 [405] = "Method Not Allowed"; -- RFC9110, Section 15.5.6
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
41 [406] = "Not Acceptable"; -- RFC9110, Section 15.5.7
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
42 [407] = "Proxy Authentication Required"; -- RFC9110, Section 15.5.8
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
43 [408] = "Request Timeout"; -- RFC9110, Section 15.5.9
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
44 [409] = "Conflict"; -- RFC9110, Section 15.5.10
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
45 [410] = "Gone"; -- RFC9110, Section 15.5.11
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
46 [411] = "Length Required"; -- RFC9110, Section 15.5.12
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
47 [412] = "Precondition Failed"; -- RFC9110, Section 15.5.13
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
48 [413] = "Content Too Large"; -- RFC9110, Section 15.5.14
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
49 [414] = "URI Too Long"; -- RFC9110, Section 15.5.15
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
50 [415] = "Unsupported Media Type"; -- RFC9110, Section 15.5.16
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
51 [416] = "Range Not Satisfiable"; -- RFC9110, Section 15.5.17
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
52 [417] = "Expectation Failed"; -- RFC9110, Section 15.5.18
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
53 [418] = "I'm a teapot"; -- RFC2324, Section 2.3.2
9170
47ffce31ffe4 net.http.codes: "Correct" range of unassigned codes (thanks pep.)
Kim Alvefur <zash@zash.se>
parents: 9167
diff changeset
54 -- [419-420] = "Unassigned";
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
55 [421] = "Misdirected Request"; -- RFC9110, Section 15.5.20
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
56 [422] = "Unprocessable Content"; -- RFC9110, Section 15.5.21
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
57 [423] = "Locked";
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
58 [424] = "Failed Dependency";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
59 [425] = "Too Early";
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
60 [426] = "Upgrade Required"; -- RFC9110, Section 15.5.22
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
61 -- [427] = "Unassigned";
6694
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
62 [428] = "Precondition Required";
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
63 [429] = "Too Many Requests";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
64 -- [430] = "Unassigned";
6694
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
65 [431] = "Request Header Fields Too Large";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
66 -- [432-450] = "Unassigned";
7572
f549587b8c06 net.http.codes: Add HTTP status code 451 Unavailable For Legal Reasons from RFC 7725
Kim Alvefur <zash@zash.se>
parents: 7571
diff changeset
67 [451] = "Unavailable For Legal Reasons";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
68 -- [452-499] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
69
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
70 [500] = "Internal Server Error"; -- RFC9110, Section 15.6.1
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
71 [501] = "Not Implemented"; -- RFC9110, Section 15.6.2
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
72 [502] = "Bad Gateway"; -- RFC9110, Section 15.6.3
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
73 [503] = "Service Unavailable"; -- RFC9110, Section 15.6.4
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
74 [504] = "Gateway Timeout"; -- RFC9110, Section 15.6.5
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
75 [505] = "HTTP Version Not Supported"; -- RFC9110, Section 15.6.6
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
76 [506] = "Variant Also Negotiates";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
77 [507] = "Insufficient Storage";
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
78 [508] = "Loop Detected";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
79 -- [509] = "Unassigned";
12548
5133d6e48686 net.http.codes: Refresh from registry, many refs now point to RFC9110
Kim Alvefur <zash@zash.se>
parents: 10370
diff changeset
80 [510] = "Not Extended"; -- (OBSOLETED)
6694
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
81 [511] = "Network Authentication Required";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
82 -- [512-599] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
83 };
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
84
10370
78bda7932f17 net.http.codes: Avoid implicit number -> string coercion
Kim Alvefur <zash@zash.se>
parents: 9170
diff changeset
85 for k,v in pairs(response_codes) do response_codes[k] = ("%03d %s"):format(k, v); end
7571
e8efb5cf0877 net.http.codes: Remove used argument
Kim Alvefur <zash@zash.se>
parents: 6694
diff changeset
86 return setmetatable(response_codes, { __index = function(_, k) return k.." Unassigned"; end })