ithewei / ithewei/libhv

Option to pass in-memory CA certificate for server verification with websocket client

Offen
#586 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C
Sterne
7.6k
Forks
1.4k
Ø Merge
1 T. 21 Std.
Gemergte PRs (30 T.)
9

Beschreibung

Verifying the websocket server's certificate requires a filename:
```cpp
// m_conn is a hv::WebSocketClient
hssl_ctx_opt_t param{};
param.endpoint = HSSL_CLIENT;
param.verify_peer = 1;
param.ca_file = "W:\\path\\to\\cert.pem";
int tls_result = m_conn.withTLS(¶m);
```
There does not seem to be an option to pass an in-memory certificate:
https://github.com/ithewei/libhv/blob/8c67e056f63c6cb4f9476d5904bef5ef9f350f12/ssl/hssl.h#L39C1-L46C41
```cpp
typedef struct {
const char* crt_file;
const char* key_file;
const char* ca_file;
const char* ca_path;
short verify_peer;
short endpoint; // HSSL_SERVER / HSSL_CLIENT
} hssl_ctx_opt_t, hssl_ctx_init_param_t;
```
The problem with passing a file name is that a client application that ships with a certificate (e.g. as an embedded QT resource file) would have to save the certificate on disk before it can be used with libhv/openssl. This allows a user of the application to tamper with the certificate which would render server verification useless.

My suggestion is to add more fields to `hssl_ctx_opt_t` to allow using an in-memory certificate (byte buffer).

Similar issue: https://stackoverflow.com/questions/5052563

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne mit ssl/hssl.h, insbesondere hssl_ctx_opt_t, und verfolge dann, wie WebSocketClient::withTLS diese Struktur verwendet. Erledigt ist die Aufgabe, wenn ein Client ein im Speicher befindliches CA-Zertifikat zur Serververifizierung bereitstellen kann, ohne es zuvor auf die Festplatte schreiben zu müssen; im Issue wird keine Testdatei genannt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, cpp
Bereich
networking, security
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.