@@ -35,7 +35,8 @@ defmodule NervesHub.Logger do
3535 [ :nerves_hub , :devices , :update , :successful ] ,
3636 [ :nerves_hub , :managed_deployments , :set_deployment_group , :none_found ] ,
3737 [ :nerves_hub , :managed_deployments , :set_deployment_group , :one_found ] ,
38- [ :nerves_hub , :managed_deployments , :set_deployment_group , :multiple_found ]
38+ [ :nerves_hub , :managed_deployments , :set_deployment_group , :multiple_found ] ,
39+ [ :nerves_hub , :ssl , :fail ]
3940 ]
4041
4142 Enum . each ( events , fn event ->
@@ -165,6 +166,40 @@ defmodule NervesHub.Logger do
165166 )
166167 end
167168
169+ def log_event ( [ :nerves_hub , :ssl , :fail ] , _ , metadata , _ ) do
170+ Logger . info ( "SSL certificate verification failed" ,
171+ event: "nerves_hub.ssl.fail" ,
172+ reason: metadata [ :reason ] ,
173+ cert_serial: metadata [ :cert_serial ] ,
174+ cert_subject: metadata [ :cert_subject ]
175+ )
176+ end
177+
178+ @ doc """
179+ The Erlang SSL application will log issues or failures related to verification of certificates.
180+
181+ This filter is designed to ignore SSL handshake errors that occur during the `:certify` state that are not helpful or hard to understand.
182+
183+ eg. TLS :server: In state :certify at ssl_handshake.erl:2201 generated SERVER ALERT: Fatal - Handshake Failure - :unknown_ca
184+ """
185+ def ssl_log_filter ( log_event , _opts ) do
186+ case log_event do
187+ % {
188+ msg:
189+ { :report ,
190+ % {
191+ alert: { :alert , _ , _ , % { file: ~c" ssl_handshake.erl" } , _ , _ } ,
192+ role: :server ,
193+ statename: :certify
194+ } }
195+ } ->
196+ :stop
197+
198+ _ ->
199+ :ignore
200+ end
201+ end
202+
168203 # Helper functions
169204
170205 defp ignore_list ( ) do
0 commit comments