diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-02-10 08:27:10 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-02-10 08:27:10 -0600 |
| commit | 0ad3a9b5b584697b43b74f68e88a31e048b32822 (patch) | |
| tree | 1624fd75ad48ad3c0ac9285969dc8d522c62168b /src | |
| parent | acedfdc4da02f10c2271d94f13e4ca9c2a5cb6b3 (diff) | |
| download | slskd-0ad3a9b5b584697b43b74f68e88a31e048b32822.tar.gz | |
docs
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Cryptography/X509.cs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/slskd/Common/Cryptography/X509.cs b/src/slskd/Common/Cryptography/X509.cs index 2f5392fd..95743cc0 100644 --- a/src/slskd/Common/Cryptography/X509.cs +++ b/src/slskd/Common/Cryptography/X509.cs @@ -21,8 +21,18 @@ namespace slskd.Common.Cryptography using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; + /// <summary> + /// X509 utility methods. + /// </summary> public static class X509 { + /// <summary> + /// Generates an X509 certificate for the specified <paramref name="subject"/>. + /// </summary> + /// <param name="subject">The certificate subject.</param> + /// <param name="password">The optional password for the certificate.</param> + /// <param name="x509KeyStorageFlags">The optional key storage flags for the certificate.</param> + /// <returns>The generated certificate.</returns> public static X509Certificate2 Generate(string subject, string password = null, X509KeyStorageFlags x509KeyStorageFlags = X509KeyStorageFlags.MachineKeySet) { password ??= Guid.NewGuid().ToString(); @@ -42,6 +52,13 @@ namespace slskd.Common.Cryptography return new X509Certificate2(certificate.Export(X509ContentType.Pkcs12, password), password, x509KeyStorageFlags); } + /// <summary> + /// Validates an X509 certificate given a PFX <paramref name="fileName"/> and optional <paramref name="password"/>. + /// </summary> + /// <param name="fileName">The path to the PFX certificate file to validate.</param> + /// <param name="password">The optional password for the certificate.</param> + /// <param name="result">The error message, if the certificate is invalid.</param> + /// <returns>A value indicating whether the certificate is valid.</returns> public static bool TryValidate(string fileName, string password, out string result) { result = null; @@ -58,4 +75,4 @@ namespace slskd.Common.Cryptography } } } -} +}
\ No newline at end of file |
