php / php/php-src

ext-mysqlnd: can't set SSL server hostname verification independent of general certificate validation

Aperta
#8,769 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Description

The mysql command line client and related tools verify SSL certificates, but by default do not verify that the server name used to connect matches the Subject CN, or one of the SAN extension entries, of the server certificate.

This additional verification needs to be requested using the --ssl-verify-server-cert option (which was not the best name for this, -ssl-verify-server-cert-hostname would have been a better choice, bu that is a different story); or when using encrypted replication: the MASTER_SSL_VERIFY_SERVER_CERT=1 option to CHANGE MASTER.

With mysqlnd though both verification aspects are tightly coupled, and can only be both on, or both off, controlled by the single MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT flag.

See also: ext/mysqlnd/mysqlnd_vio.c:

555                 ZVAL_BOOL(&verify_peer_zval, verify);
556                 php_stream_context_set_option(context, "ssl", "verify_peer", &verify_peer_zval);
557                 php_stream_context_set_option(context, "ssl", "verify_peer_name", &verify_peer_zval);

https://github.com/php/php-src/blob/master/ext/mysqlnd/mysqlnd_vio.c#L555

There needs to be an extra option like MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_HOSTNAME to control hostname verification independent of general certificate verification.

PHP Version

PHP 8.1.2

Operating System

Ubuntu 22.04

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

Leggi ext/mysqlnd/mysqlnd_vio.c intorno alle righe 555–557, dove verify_peer e verify_peer_name vengono impostati insieme, e rivedi il flag MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT. La modifica è completa quando la verifica del nome host può essere controllata indipendentemente tramite un’opzione aggiuntiva, mentre la validazione generale del certificato rimane controllabile separatamente.

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

Valutazione

Stack tecnologico
c, mysql
Ambito
databases, security
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.