Skip to content

Commit

Permalink
server config: for each certificate chain some signature_algorithm mu…
Browse files Browse the repository at this point in the history
…st be there

(TLS 1.2+ only) - if the configured set of certificate chains cannot be used
since no signature algorithm can be used
  • Loading branch information
hannesm committed Sep 13, 2021
1 parent c5023de commit fc0ed4a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,29 @@ let validate_server config =
| _ -> () );
{ config with ciphers }

let validate_keys_sig_algs config =
let _, v_max = config.protocol_versions in
if v_max = `TLS_1_2 || v_max = `TLS_1_3 then
let certificate_chains =
match config.own_certificates with
| `Single c -> [c]
| `Multiple cs -> cs
| `Multiple_default (c, cs) -> c :: cs
| `None -> invalid "no server certificate provided"
in
let server_keys =
List.map (function
| (s::_,_) -> X509.Certificate.public_key s
| _ -> invalid "empty certificate chain")
certificate_chains
in
if not
(List.for_all (fun cert ->
List.exists (pk_matches_sa cert) config.signature_algorithms)
server_keys)
then
invalid "certificate provided which does not allow any signature algorithm"

type client = config [@@deriving sexp_of]
type server = config [@@deriving sexp_of]

Expand Down Expand Up @@ -550,6 +573,7 @@ let server
} in
let config = validate_server config in
let config = validate_common config in
validate_keys_sig_algs config;
Log.debug (fun m -> m "server with %s"
(Sexplib.Sexp.to_string_hum (sexp_of_config config)));
config

0 comments on commit fc0ed4a

Please sign in to comment.