Throw exception if the Private Key is null
authorCarlos Guzmán Álvarez <carlos@mono-cvs.ximian.com>
Tue, 10 Feb 2004 11:54:50 +0000 (11:54 -0000)
committerCarlos Guzmán Álvarez <carlos@mono-cvs.ximian.com>
Tue, 10 Feb 2004 11:54:50 +0000 (11:54 -0000)
svn path=/trunk/mcs/; revision=22942

mcs/class/Mono.Security/ChangeLog
mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs

index 6641a03ee86750fefe2f1cf75b95509a09fec212..e2c3d9e28403ee88b8757785c8858d52056f6f71 100644 (file)
@@ -1,5 +1,9 @@
 2004-02-10 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
 
+    * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+        - Throw exception if the Private Key is null.
+
     * Mono.Security.Protocol.Tls/SslServerStream.cs:
 
         - Ssl Server class without implementation ( methods signatures only )
index f5c6d05a6603261ffa853137e026f4a462c7b6db..d88e3303bceac5949253e48836f9fc73165b680e 100644 (file)
@@ -60,23 +60,32 @@ namespace Mono.Security.Protocol.Tls.Handshake.Client
 
                protected override void ProcessAsTls1()
                {
-                       AsymmetricAlgorithm privKey = this.Context.SslStream.RaisePrivateKeySelection(
+                       AsymmetricAlgorithm privKey = null;
+                       
+                       privKey = this.Context.SslStream.RaisePrivateKeySelection(
                                this.Context.ClientSettings.ClientCertificate,
                                this.Context.ClientSettings.TargetHost);
 
-                       // Compute handshake messages hash
-                       MD5SHA1 hash = new MD5SHA1();
-                       hash.ComputeHash(
-                               this.Context.HandshakeMessages.ToArray(),
-                               0,
-                               (int)this.Context.HandshakeMessages.Length);
-
-                       // RSAManaged of the selected ClientCertificate 
-                       // (at this moment the first one)
-                       RSA rsa = getClientCertRSA((RSA)privKey);
-
-                       // Write message
-                       Write(hash.CreateSignature(rsa));
+                       if (privKey == null)
+                       {
+                               throw this.Context.CreateException("Client certificate Private Key unavailable.");
+                       }
+                       else
+                       {
+                               // Compute handshake messages hash
+                               MD5SHA1 hash = new MD5SHA1();
+                               hash.ComputeHash(
+                                       this.Context.HandshakeMessages.ToArray(),
+                                       0,
+                                       (int)this.Context.HandshakeMessages.Length);
+
+                               // RSAManaged of the selected ClientCertificate 
+                               // (at this moment the first one)
+                               RSA rsa = this.getClientCertRSA((RSA)privKey);
+
+                               // Write message
+                               this.Write(hash.CreateSignature(rsa));
+                       }
                }
 
                #endregion