< prev index next >

src/java.base/share/classes/sun/security/ssl/RSAClientKeyExchange.java

Print this page

        

@@ -66,11 +66,12 @@
     @SuppressWarnings("deprecation")
     RSAClientKeyExchange(ProtocolVersion protocolVersion,
             ProtocolVersion maxVersion,
             SecureRandom generator, PublicKey publicKey) throws IOException {
         if (publicKey.getAlgorithm().equals("RSA") == false) {
-            throw new SSLKeyException("Public key not of type RSA");
+            throw new SSLKeyException("Public key not of type RSA: " + 
+                publicKey.getAlgorithm());
         }
         this.protocolVersion = protocolVersion;
 
         try {
             String s = protocolVersion.useTLS12PlusSpec() ?

@@ -98,11 +99,12 @@
             ProtocolVersion maxVersion,
             SecureRandom generator, HandshakeInStream input,
             int messageSize, PrivateKey privateKey) throws IOException {
 
         if (privateKey.getAlgorithm().equals("RSA") == false) {
-            throw new SSLKeyException("Private key not of type RSA");
+            throw new SSLKeyException("Private key not of type RSA: " + 
+                 privateKey.getAlgorithm());
         }
 
         if (currentVersion.useTLS10PlusSpec()) {
             encrypted = input.getBytes16();
         } else {

@@ -159,12 +161,12 @@
                 preMaster = (SecretKey)cipher.unwrap(encrypted,
                         "TlsRsaPremasterSecret", Cipher.SECRET_KEY);
             }
         } catch (InvalidKeyException ibk) {
             // the message is too big to process with RSA
-            throw new SSLProtocolException(
-                "Unable to process PreMasterSecret, may be too big");
+            throw new SSLException(
+                "Unable to process PreMasterSecret", ibk);
         } catch (Exception e) {
             // unlikely to happen, otherwise, must be a provider exception
             if (debug != null && Debug.isOn("handshake")) {
                 System.out.println("RSA premaster secret decryption error:");
                 e.printStackTrace(System.out);
< prev index next >