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

TLS certificate with validity of decades results in an exception when querying /api/health/checks/certificate-expiration/1/months #12464

Open
hvt opened this issue Oct 7, 2024 · 4 comments
Assignees
Labels

Comments

@hvt
Copy link

hvt commented Oct 7, 2024

Describe the bug

We are using RabbitMQ 3.12.12.

Because of reasons (tm) we have a TLS certificate with an extremely long validity (and also signed by a CA that has that same validity period), namely:

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            2d:b6:9b:eb:04:7d:ad:32:d8:ae:3b:4d:58:02:5c:af:fe:59:cb:3c
        Signature Algorithm: sha512WithRSAEncryption
        Issuer: CN = RabbitMQ Example CA
        Validity
            Not Before: Jan  1 00:00:00 1970 GMT
            Not After : Dec 31 23:59:59 2099 GMT
        Subject: CN = rabbitmq.example.org
        ...

When you now query the health check API for certificate expiration, you receive a HTTP 500 response, without any content.
In the logs of RabbitMQ, this crash / traceback is printed:

2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>   crasher:
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     initial call: cowboy_stream_h:request_process/3
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     pid: <0.18355.14>
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     registered_name: []
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     exception error: an error occurred when evaluating an arithmetic expression
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in operator  div/2
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>          called as {error,"Certificate is not yet valid"} div 86400
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in call from calendar:gregorian_seconds_to_datetime/1 (calendar.erl, line 192)
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in call from rabbit_mgmt_wm_health_check_certificate_expiration:seconds_to_bin/1 (rabbit_mgmt_wm_health_check_certificate_expiration.erl, line 176)
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in call from rabbit_mgmt_wm_health_check_certificate_expiration:'-expires_on_list/1-lc$^0/1-0-'/1 (rabbit_mgmt_wm_health_check_certificate_expiration.erl, line 123)
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in call from rabbit_mgmt_wm_health_check_certificate_expiration:listener_expiring_within/2 (rabbit_mgmt_wm_health_check_certificate_expiration.erl, line 115)
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in call from rabbit_mgmt_wm_health_check_certificate_expiration:'-to_json/2-fun-1-'/3 (rabbit_mgmt_wm_health_check_certificate_expiration.erl, line 46)
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in call from lists:foldl_1/3 (lists.erl, line 1355)
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>       in call from rabbit_mgmt_wm_health_check_certificate_expiration:to_json/2 (rabbit_mgmt_wm_health_check_certificate_expiration.erl, line 45)
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     ancestors: [<0.18354.14>,<0.608.0>,<0.603.0>,<0.602.0>,<0.600.0>,
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>                   rabbit_web_dispatch_sup,<0.553.0>]
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     message_queue_len: 0
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     messages: []
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     links: [<0.18354.14>]
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     dictionary: []
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     trap_exit: false
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     status: running
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     heap_size: 6772
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     stack_size: 28
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>     reductions: 12142
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14>   neighbours:
2024-10-06 05:33:53.592394+00:00 [error] <0.18355.14> 
2024-10-06 05:33:53.594071+00:00 [error] <0.18354.14> Ranch listener {acceptor,{0,0,0,0,0,0,0,0},5673}, connection process <0.18354.14>, stream 1 had its request process <0.18355.14> exit with reason badarith and stacktrace [{erlang,'div',[{error,"Certificate is not yet valid"},86400],[{error_info,#{module => erl_erts_errors}}]},{calendar,gregorian_seconds_to_datetime,1,[{file,"calendar.erl"},{line,192}]},{rabbit_mgmt_wm_health_check_certificate_expiration,seconds_to_bin,1,[{file,"rabbit_mgmt_wm_health_check_certificate_expiration.erl"},{line,176}]},{rabbit_mgmt_wm_health_check_certificate_expiration,'-expires_on_list/1-lc$^0/1-0-',1,[{file,"rabbit_mgmt_wm_health_check_certificate_expiration.erl"},{line,123}]},{rabbit_mgmt_wm_health_check_certificate_expiration,listener_expiring_within,2,[{file,"rabbit_mgmt_wm_health_check_certificate_expiration.erl"},{line,115}]},{rabbit_mgmt_wm_health_check_certificate_expiration,'-to_json/2-fun-1-',3,[{file,"rabbit_mgmt_wm_health_check_certificate_expiration.erl"},{line,46}]},{lists,foldl_1,3,[{file,"lists.erl"},{line,1355}]},{rabbit_mgmt_wm_health_check_certificate_expiration,to_json,2,[{file,"rabbit_mgmt_wm_health_check_certificate_expiration.erl"},{line,45}]}]
2024-10-06 05:33:53.594071+00:00 [error] <0.18354.14> 

Reproduction steps

I am not entirely sure if this is caused by the CA validity or the certificate validity.
I have however generated an example CA certificate and an example certificate + key:

  • `ca.crt`
    -----BEGIN CERTIFICATE-----
    MIIFKTCCAxGgAwIBAgIUH7VQuNxYNBgBFwUdwIsaMxLsXKgwDQYJKoZIhvcNAQEN
    BQAwHjEcMBoGA1UEAwwTUmFiYml0TVEgRXhhbXBsZSBDQTAgFw03MDAxMDEwMDAw
    MDBaGA8yMDk5MTIzMTIzNTk1OVowHjEcMBoGA1UEAwwTUmFiYml0TVEgRXhhbXBs
    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2/rMPY2P+RHM6Bb9qd3VyQEll/Jz+e4mmS3p1kATz1Y5DQyZjvO
    hhlZGguIauSh+hsuY0TGLNfOW7oxEiVZTFeh7M84P451H6D/vQ0AJp0MmUDoxE7X
    qNNdrWv3hVJi+lPHTQk/oGMIleiHgxRwnDWydzGqIVJjbQqBr+a7giD/UuTY4Akt
    DbeHwNMO0gHh9RJBxGFp1SwJObzbvGEz6At/m9oDbOSvdS3DWe+MFgnrwIx6Gdmc
    zhUo9silIdqNV945EmjG4Ze52hN0d52IpdeIb4CD4tj0MMkpsyDg7JnrYsXaMgHB
    31I4PkdF40GuJ1SWRMGGtJwYUCYSBDkVQexTC6v+LWIQyYNgOpgIMkonTJFg4PQ4
    4MtQstxrGpmzNUc40Rcwx6m2TW4orM7Gg1w6qJQhWHxBFWboGYvOvjSHscjfZMfZ
    tdl96b5xVd8SRfO+fzwRQD8mIS1IhMwmLGQ0nfWBzQPmyizk0IgOZntpBa+vOG5T
    3D6rVmSoeDY6s9Fq1VAckUPnPIUVC2IIa15OG8Y=
    -----END CERTIFICATE-----
    
  • `server.crt`
    -----BEGIN CERTIFICATE-----
    MIIFmTCCA4GgAwIBAgIULbab6wR9rTLYrjtNWAJcr/5ZyzwwDQYJKoZIhvcNAQEN
    BQAwHjEcMBoGA1UEAwwTUmFiYml0TVEgRXhhbXBsZSBDQTAgFw03MDAxMDEwMDAw
    MDBaGA8yMDk5MTIzMTIzNTk1OVowHzEdMBsGA1UEAwwUcmFiYml0bXEuZXhhbXBs
    ZS5vcmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDm5G/f+FSxgv5c
    6x9RneFzF+KFs6Z2tkrkA2hx94cS6TQgprtL28WeEFTjglbUs2LNgkbbS9ZIVfo6
    /gcGQbjMije84+B4PYG+VZJRvpcDAXha1TQw+LHepF7ORJilxpk+q7qhTMX3JW87
    JKuCZgxGbQjuuZ+jpvavclVBrFWZ8+QXsnTuN/16/KGFctAUzfUZOD/RL7zA3LR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zBqNR1SJ3gJiMj4pZ5csEWvEFlnvT3twVA/SzlXWFrOHeoDVSSdEXDC
    cL2LaqJ5nzVB9G4sE0sufgb7/gBXesrr+yKlaS9iP+bgSmGi/zDbEVJCdQyWeolI
    1fokvqdjffeyr3TCwes5xkykY1vB/JJ0qqAW1K2FZwQist1GDZgecIWxO6zvFZ7O
    95i8B6i4IGrT5jPYMLyLzgzAb2MBYzCccAZkGedmYnVNHi0vND8MLnt3CZHS48A1
    rTl0/WA6920EWJEqDSZsXbwO5eB6V5l4v2GlG8FzKAEnkzeXbdxKsXnxXlxQg07I
    45UIVcrGP/vOAy5mlTHQjspB8YqPXx6JoHgMvWHMpRcrUZb1GJBqT+U2sG+4dh+w
    1bykhZokWborXY1q7Xdfp18qYWQNfbHOg6l6M1q5bqLPWY77wX09JQGNQPa3
    -----END CERTIFICATE-----
    
  • `server.key`
    -----BEGIN PRIVATE KEY-----
    MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDm5G/f+FSxgv5c
    6x9RneFzF+KFs6Z2tkrkA2hx94cS6TQgprtL28WeEFTjglbUs2LNgkbbS9ZIVfo6
    /gcGQbjMije84+B4PYG+VZJRvpcDAXha1TQw+LHepF7ORJilxpk+q7qhTMX3JW87
    JKuCZgxGbQjuuZ+jpvavclVBrFWZ8+QXsnTuN/16/KGFctAUzfUZOD/RL7zA3LRl
    7c123ROUesffZjTk2AODcnQI8lnLLfgEdhAYl/jVZjF617y7Fk3JaAhKJuIjo9uN
    EaheAx9qSgjciKRWzz7JCXUG+lZrpwU1GzA1t0Ja+VGHXvxTCnNUq0Eng60Ahvv2
    0VXnipn84lxlBL8a3FEIbV36ixE79KnaTSajYp68JAuOIinq+wHV8RdnsMS1mc60
    evzBl9XVBLE41TSNGWDssNjMPOJCJRWs6CPqp0CRMfZy5C99vSumXOo6aupCrRXD
    wVkhYVh8bE6xyy6Jpn+7o7qhYoXOez/3KfIxTzx0Tx+7Rjcwa2ck6LehocXfZxxV
    NMsI8tOTcD2gGXqsx4sblg8+2QtHlFmwqKxshIm09NBCY8ojYoqgHEdh75MmvPbr
    9FkmVKUPa6Am7jDpApoQWVO9B8qENLGu5Bz4RLybjIFrDf/BkdVOwF2VqCCZXspY
    hSFN8RGfz3RVGN2CFAKu3Js09Z/rIQIDAQABAoICAAcvtv4ZyzEKaoMj2+hJz+Zc
    9cAplK9lm+eEf6MeDCzRG1ek0nfy+C/XD31UfwIrYl9F6pF3k8zRxQvbzWyRbebX
    3avZ/90rAbdiqT8BsQH3JFk9zfXapInRREe+Dm48EMr791jlfDsY0pR2eLjo484e
    JXgHFdC3KQue6GGdGb3Ev79JEg1tqrMOp+Xw0K8rfEraDr2ipoi6/DzSVC6auCBL
    J56f0Y4J3Y1Uage/qBg3bw/C4o9eM4pMBJNvoY0rjYvZdBPMXNK1J+eeunnRAqpO
    CzNdNJg+TRSR+cixnZaUlTuChCA34WKjF4ZTtR2a83bM+b/45jdgL1/bdh84/iZR
    fEOLAJgNMDPu46iGOugFKkQfscz7iItH4jAARWwhOjvup/LmLdgLdo92DiIB2P4N
    ba920aYS4NoEutH9IQ1RHKaOzFXbIFd4CS4ArN83uDjIRRsKN4YwNomAuv+N7ehd
    h/7PEsG6/a0nvjcmc+H4UjAM0Xv+LFlvFOG1lpKm8U6nxmYfK/vvk0yM2EwPCx6/
    Ugh7xkde3GXLXTpse30fTq1n3hL9I2fYf9FIWaa5SFzmP5eJHZPgI/vZQEzR0FTe
    DoXW9QOL8R0+9Zl5+1fissR6cht6+HCeK/hmCX65H24IGfz2Cyi6i7d6P83VQ0k2
    s0Dr7cACMvYSZorYt2WRAoIBAQD46abjRVo0YQ4gNUWPwwwzFmOptJnkFKw9ywT7
    KOFkEaOzbClrkguMNWFYAF9G33ewGKkNL5AeexWSdO18QaOPXSLElE0lnlNOV18b
    tv2T+cA7rCO8g766cXCSGS9ZRqPThX24ntBRHiIailjKOk3tQOX41CIqTZaaDxvg
    UMAg66KmSxfeA8sHKmzIA5K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AJn1rfykssl60ueUCseGhtdZW
    uH3Aa52LGE7FHu4kaftrduI+L+Wga4NmreLL0AAVoG1CodtkMF0YG+touXHQn4Pb
    njql4qLVEbYpLDdSN2So32Rt3ODhoIX2NUDHGMsKjZN+7ubmgOY5u6yuT2kvg/mY
    G70CggEANwi4GCTA3wgUq8lDAh2HhaRxp2OBL64cu5JSYW7V+wDywo7hLJYrHy/1
    Pjq1aQN6min1c7MvASoFHnM1WJK3bcbQFa0Avpk4f88wLoTbsw15HpuD5GeAMjB6
    O3Jl7eMZ3ZJzX5m1twdQgBoCheC0ENAEjxNbw0sr3y7jw9sp5Z/nUck+FsRVLV31
    OdMCWhOiDipxnyqZxYWZmmU/secuTjFecIWad0W5ys7lnzCL8wDGL8+ImKQJSa53
    g2qxlqNMo329z+dvhLxxLjy1xiCQh1479w+HMtau5chOE78JxgJGDC7wQoX41H6P
    jM4F8+WkAgd+Do4SYPH5bBpSf+V6FA==
    -----END PRIVATE KEY-----
    
    
  1. I am referencing these three files in rabbitmq.conf like this:
    ssl_options.cacertfile = ca.crt
    ssl_options.certfile   = server.crt
    ssl_options.keyfile    = server.key
    
  2. When you now try querying the API health check for certificate expirations, you get:
    $ curl --verbose --user admin:password http://localhost:5673/api/health/checks/certificate-expiration/1/months
    *   Trying 127.0.0.1:5673...
    * Connected to localhost (127.0.0.1) port 5673 (#0)
    * Server auth using Basic with user 'admin'
    > GET /api/health/checks/certificate-expiration/1/months HTTP/1.1
    > Host: localhost:5673
    > Authorization: Basic ...
    > User-Agent: curl/7.81.0
    > Accept: */*
    > 
    * Mark bundle as not supporting multiuse
    < HTTP/1.1 500 Internal Server Error
    < content-length: 0
    < 
    * Connection #0 to host localhost left intact

Expected behavior

Not triggering a HTTP 500 and not listing the certificate as being about to expire.

Additional context

No response

@hvt hvt added the bug label Oct 7, 2024
@lukebakken lukebakken self-assigned this Oct 7, 2024
@michaelklishin michaelklishin changed the title TLS certificate with long validity results in badarith when querying /api/health/checks/certificate-expiration/1/months TLS certificate with long (decades) validity results in badarith when querying /api/health/checks/certificate-expiration/1/months Oct 7, 2024
@michaelklishin michaelklishin changed the title TLS certificate with long (decades) validity results in badarith when querying /api/health/checks/certificate-expiration/1/months TLS certificate with validity of decades results in an exception when querying /api/health/checks/certificate-expiration/1/months Oct 7, 2024
@michaelklishin
Copy link
Member

3.12 has been out of support for more than 6 months.

So we will be trying to reproduce this against 4.0.2, the only community-supported series.

The standard expiration period used by tls-gen is 10 years. In theory overriding it to be 50 years or something should be enough.

@lukebakken
Copy link
Collaborator

Here is where the Certificate is not yet valid error message is generated:

https://github.com/rabbitmq/rabbitmq-server/blob/main/deps/rabbitmq_management/src/rabbit_mgmt_wm_health_check_certificate_expiration.erl#L137-L161

@hvt you've probably found an edge case that the code misses. I'll investigate this when I can find time.

What happens if your certs have a slightly later start time, like epoch time plus 1 second?

@hvt
Copy link
Author

hvt commented Oct 7, 2024

What happens if your certs have a slightly later start time, like epoch time plus 1 second?

At first I thought it was a division by zero. So I already tried creating a certificate (and CA) with a Not Before of Jan 1 00:00:01 1970 GMT. That failed as well, with the same error.

@michaelklishin
Copy link
Member

The code computes the difference between dates in seconds, so something may not be accounting for overflow/wrap around in one of the calendar modules.

In some if not all cases we could use minutes or hours. This health check is meant to be run e.g. every day, not every hour or minute.

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

No branches or pull requests

3 participants