php / php/php-src

check_cert() insists on all provided certificates to validate against system CA store

Aperta
#8,371 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Extension: openssl Feature
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

Description

The following code:

php -r  "var_dump(openssl_x509_checkpurpose(file_get_contents('v_crt.pem'), X509_PURPOSE_SSL_SERVER, array('v_ca.pem')));"

Resulted in this output:

bool(false)

But I expected this output instead:

bool(true)

where v_cert.pem contains any letsencrypt issued certificate, v_ca.pem contains two intermediate certs (it's default chain from letsencrypt):
a)
Issuer: C = US, O = Internet Security Research Group, CN = ISRG Root X1
Subject: C = US, O = Let's Encrypt, CN = R3
b)
Issuer: O = Digital Signature Trust Co., CN = DST Root CA X3
Subject: C = US, O = Internet Security Research Group, CN = ISRG Root X1

b) is issued by "DST Root CA X3" which is already expired certificate [1] that (this is important) no longer exists in local (system wide) ca-certificates store (verify that on your ca-certificates store).

openssl_x509_checkpurpose() uses check_cert() which calls X509_verify_cert().

Behaviour of this is all intermediate certs need to validate agains system ca store otherwise check fails. It will fail EVEN if we have one chain path that validates agains our ca system store.

Impact of this is that perfectly valid certificate chains are considered to be not ok for any purpose.

There is a flag that changes this bahaviour to say "ok" when at least single validated chain is found - X509_V_FLAG_PARTIAL_CHAIN. It makes logic sense for what openssl_x509_checkpurpose() is trying to do.

Some other users of this flag:
https://github.com/curl/curl/pull/4655
https://github.com/curl/curl/pull/4655/commits/146ccff7a7c9cdc5bfc9d4f2076a9e57a03c1eb8
https://github.com/noxxi/p5-io-socket-ssl/blob/master/lib/IO/Socket/SSL.pm#L2475

  1. https://community.letsencrypt.org/t/production-chain-changes/150739/3
PHP Version

PHP 8.1.4

Operating System

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il comando PHP nell’issue, quindi segui openssl_x509_checkpurpose() attraverso check_cert() fino a X509_verify_cert(). Confronta il comportamento attuale della verifica con X509_V_FLAG_PARTIAL_CHAIN e conferma che una catena alternativa valida abbia esito positivo senza il certificato scaduto; aggiungi o aggiorna la coverage per questo caso di catena di certificati prima di verificare il risultato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, php
Ambito
cryptography, security
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.