diff options
| author | 2024-02-19 18:46:05 +0000 | |
|---|---|---|
| committer | 2024-02-19 18:46:05 +0000 | |
| commit | ebd03383f856bfaa72b1700a96561396e6f8f6cc (patch) | |
| tree | 47651f7a9c8567ae020c6b8750db58a7d3c2da2b /include/modules/ssl.h | |
| parent | Fix more issues with the v3 compat layer. (diff) | |
Allow using multiple SSL fingerprint algorithms.
Closes #1804.
Diffstat (limited to 'include/modules/ssl.h')
| -rw-r--r-- | include/modules/ssl.h | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/include/modules/ssl.h b/include/modules/ssl.h index 1540f6385..bde05a5b8 100644 --- a/include/modules/ssl.h +++ b/include/modules/ssl.h @@ -45,7 +45,7 @@ public: std::string dn; std::string issuer; std::string error; - std::string fingerprint; + std::vector<std::string> fingerprints; bool trusted = false; bool invalid = true; bool unknownsigner = true; @@ -79,12 +79,20 @@ public: return error; } - /** Get key fingerprint. - * @return The key fingerprint as a hex string. + /** Get primary fingerprint. + * @return The primary fingerprint as a hex string. */ - const std::string& GetFingerprint() const + std::string GetFingerprint() const { - return fingerprint; + return fingerprints.empty() ? "" : fingerprints.front(); + } + + /** Get all fingerprints. + * @return All fingerprints as a hex string. + */ + const std::vector<std::string>& GetFingerprints() const + { + return fingerprints; } /** Get trust status @@ -333,9 +341,9 @@ public: */ virtual void SetCertificate(User* user, ssl_cert* cert) = 0; - /** Get the key fingerprint from a user's certificate - * @param user The user whose key fingerprint to get, user may be remote - * @return The key fingerprint from the user's TLS certificate or an empty string + /** Get the primary fingerprint from a user's certificate + * @param user The user whose primary fingerprint to get. + * @return The primary fingerprint from the user's TLS certificate or an empty string * if the user is not using TLS or did not provide a client certificate */ std::string GetFingerprint(User* user) @@ -345,6 +353,19 @@ public: return cert->GetFingerprint(); return ""; } + + /** Get all fingerprint from a user's certificate + * @param user The user whose fingerprint to get. + * @return The fingerprint from the user's TLS certificate or an empty string + * if the user is not using TLS or did not provide a client certificate + */ + std::vector<std::string> GetFingerprints(User* user) + { + ssl_cert* cert = GetCertificate(user); + if (cert) + return cert->GetFingerprints(); + return {}; + } }; /** API implemented by m_sslinfo that allows modules to retrieve the TLS certificate |
