This is a status update.
I have not sorted out how to get Cloudflare Workers to request the certificate for mTLS when the CA for the Cloudflare Workers does not match the CA that signed the client certificate. Here's a request from cURL and the
request.cf object (with irrelevant properties removed) that the Cloudflare Worker sees:
$ curl --max-time 20 -X POST --data-urlencode "rawHostname=foobarbaz" --data-urlencode "email=
f...@bar.com" -H "X-Sand: cats" -H "Accept: text/plain" --cert id_rsa.private_combined -v
https://35b1222b.sandcats.pages.dev/mtls-testNote: Unnecessary use of -X or --request, POST is already inferred.
* Trying 188.114.96.1:443...
* Connected to
35b1222b.sandcats.pages.dev (188.114.96.1) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN: server accepted h2
* Server certificate:
* subject: CN=
sandcats.pages.dev* start date: Dec 23 07:42:53 2023 GMT
* expire date: Mar 22 07:42:52 2024 GMT
* subjectAltName: host "
35b1222b.sandcats.pages.dev" matched cert's "*.
sandcats.pages.dev"
* issuer: C=US; O=Google Trust Services LLC; CN=GTS CA 1P5
* SSL certificate verify ok.
* using HTTP/2
* h2 [:method: POST]
* h2 [:scheme: https]
* h2 [:authority:
35b1222b.sandcats.pages.dev]
* h2 [:path: /mtls-test]
* h2 [user-agent: curl/8.1.2]
* h2 [x-sand: cats]
* h2 [accept: text/plain]
* h2 [content-length: 41]
* h2 [content-type: application/x-www-form-urlencoded]
* Using Stream ID: 1 (easy handle 0x7f7cc7011e00)
> POST /mtls-test HTTP/2
> Host:
35b1222b.sandcats.pages.dev> User-Agent: curl/8.1.2
> X-Sand: cats
> Accept: text/plain
> Content-Length: 41
> Content-Type: application/x-www-form-urlencoded
>
* We are completely uploaded and fine
< HTTP/2 200
< date: Thu, 04 Jan 2024 18:11:20 GMT
< content-type: text/plain;charset=UTF-8
< content-length: 1497
< report-to: {"endpoints":[{"url":"https:\/\/
a.nel.cloudflare.com\/report\/v3?s=SdG2JF%2FGB5Dazq0qpC%2ByQ9qzQwYwfc1VqQrriYQT%2FlsrrI7eHA%2F0%2BT2cCGkE%2Bc5TgMkUgh0Mp5Lu6%2BKQI7iRdLdeHAGscCeFR9WtHOPffoV8gUONxGfCqFZ%2BsEk7Zp62iCw4CK%2FXYcFr6HWTUvA%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< cf-ray: 84057182bc65b45b-HKG
< alt-svc: h3=":443"; ma=86400
<
* Connection #0 to host
35b1222b.sandcats.pages.dev left intact
{"httpProtocol":"HTTP/2","tlsCipher":"AEAD-AES256-GCM-SHA384","tlsClientAuth":{"certIssuerDNLegacy":"","certIssuerSKI":"","certSubjectDNRFC2253":"","certSubjectDNLegacy":"","certFingerprintSHA256":"","certNotBefore":"","certSKI":"","certSerial":"","certIssuerDN":"","certVerified":"NONE","certNotAfter":"","certSubjectDN":"","certPresented":"0","certRevoked":"0","certIssuerSerial":"","certIssuerDNRFC2253":"","certFingerprintSHA1":""},"tlsExportedAuthenticator":{"clientFinished":"faa51032df8a81cc50998ee61094e2461278d2c87b958daab49b768f2645b362cd4a43b3b386ee4603f7c2915de35768","clientHandshake":"4ff562d4369b021af26ca368519655f442d238b6d5af3538af980d3f1128c55cd18b0e96e8194f1d9cc1e03f07e1468c","serverHandshake":"929b7a5f611f3f214edaa945f9462bcb3fc400c0f5ad02756be54ca1b127be3af0631bce9c9aa54cea9f382e177501c5","serverFinished":"84f8c0b29c56a7d9ed437aa872adc957a2fa4eb834c9e4d68e11cdd0e15861ad758c11ff6876c4134dda882c9637ceb0"},"tlsVersion":"TLSv1.3","colo":"HKG","verifiedBotCategory":"","edgeRequestKeepAliveStatus":1,"requestPriority":"weight=16;exclusive=0;group=0;group-weight=0","pagesHostName":"
35b1222b.sandcats.pages.dev","botManagement":{"corporateProxy":false,"verifiedBot":false,"jsDetection":{"passed":false},"staticResource":false,"detectionIds":{},"score":99}}
$ curl --max-time 20 --data-urlencode "rawHostname=<hostname>" --data-urlencode "email=<private>" -H "X-Sand: cats" -H "Accept: text/plain" --cert id_rsa.private_combined -v
https://sandcats.io/register * Trying 104.197.28.173:443...
* Connected to
sandcats.io (104.197.28.173) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Request CERT (13):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Certificate (11):* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS handshake, CERT verify (15):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
* subject: CN=
sandcats.io* start date: Dec 29 03:39:54 2023 GMT
* expire date: Mar 28 03:39:53 2024 GMT
* subjectAltName: host "
sandcats.io" matched cert's "
sandcats.io"
* issuer: C=US; O=Let's Encrypt; CN=R3
* SSL certificate verify ok.
* using HTTP/1.x
> POST /register HTTP/1.1
> Host:
sandcats.io> User-Agent: curl/8.1.2
> X-Sand: cats
> Accept: text/plain
> Content-Length: 53
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 400 Bad Request
< Server: nginx/1.9.11
< Date: Thu, 04 Jan 2024 07:13:21 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
<
* Connection #0 to host
sandcats.io left intact
I will continue research on this in several days.