@@ -12,15 +12,34 @@ namespace MLAPI.Cryptography
12
12
/// </summary>
13
13
public static class CryptographyHelper
14
14
{
15
+ /// <summary>
16
+ /// The delegate type used to validate certificates
17
+ /// </summary>
18
+ /// <param name="certificate">The certificate to validate</param>
19
+ /// <param name="hostname">The hostname the certificate is claiming to be</param>
15
20
public delegate bool VerifyCertificateDelegate ( X509Certificate2 certificate , string hostname ) ;
21
+ /// <summary>
22
+ /// The delegate to invoke to validate the certificates
23
+ /// </summary>
16
24
public static VerifyCertificateDelegate OnValidateCertificateCallback = null ;
17
25
26
+ /// <summary>
27
+ ///
28
+ /// </summary>
29
+ /// <param name="certificate">The certificate to validate</param>
30
+ /// <param name="hostname">The hostname the certificate is claiming to be</param>
31
+ /// <returns>Whether or not the certificate is considered valid</returns>
18
32
public static bool VerifyCertificate ( X509Certificate2 certificate , string hostname )
19
33
{
20
34
if ( OnValidateCertificateCallback != null ) return OnValidateCertificateCallback ( certificate , hostname ) ;
21
35
return certificate . Verify ( ) && ( hostname == certificate . GetNameInfo ( X509NameType . DnsName , false ) || hostname == "127.0.0.1" ) ;
22
36
}
23
37
38
+ /// <summary>
39
+ /// Gets the aes key for any given clientId
40
+ /// </summary>
41
+ /// <param name="clientId">The clientId of the client whose aes key we want</param>
42
+ /// <returns>The aes key in binary</returns>
24
43
public static byte [ ] GetClientKey ( uint clientId )
25
44
{
26
45
if ( NetworkingManager . singleton . isServer )
@@ -44,6 +63,10 @@ public static byte[] GetClientKey(uint clientId)
44
63
}
45
64
}
46
65
66
+ /// <summary>
67
+ /// Gets the aes key for the server
68
+ /// </summary>
69
+ /// <returns>The servers aes key</returns>
47
70
public static byte [ ] GetServerKey ( )
48
71
{
49
72
if ( NetworkingManager . singleton . isServer )
0 commit comments