title: JRE 7 SSL Exception UnsupportedOperationException
body: <p>I have an applet that attempts to fetch content from a specific HTTPS URL. 
  I used the following sample code:</p>
  
  <pre><code>URL url = new URL(urlLink);
  
  URLConnection urlConn = (URLConnection)url.openConnection(); //https:link
  urlConn.setDoInput(true);
  urlConn.setDoOutput(true);
  urlConn.setUseCaches(false);
  
  urlConn.setRequestProperty("Accept-Language","en");
  urlConn.setAllowUserInteraction(false);
  urlConn.setRequestProperty("Content-length",String.valueOf(data.length()));
  urlConn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
  
  DataOutputStream out=new DataOutputStream(urlConn.getOutputStream());
  out.writeBytes(data);
  out.flush();
  out.close();
  </code></pre>
  
  <p>I intermittently receive the following exception:</p>
  
  <pre><code>*** ServerHelloDone
  [read] MD5 and SHA1 hashes:  len = 4
  0000: 0E 00 00 00                                        ....
  AWT-EventQueue-2, handling exception: java.lang.UnsupportedOperationException
  %% Invalidated:  [Session-6, SSL_RSA_WITH_RC4_128_MD5]
  AWT-EventQueue-2, SEND TLSv1 ALERT:  fatal, description = internal_error
  AWT-EventQueue-2, WRITE: TLSv1 Alert, length = 2
  [Raw write]: length = 7
  0000: 15 03 01 00 02 02 50                               ......P
  AWT-EventQueue-2, called closeSocket()
  AWT-EventQueue-2, called close()
  AWT-EventQueue-2, called closeInternal(true)
  
  javax.net.ssl.SSLException: java.lang.UnsupportedOperationException
          at sun.security.ssl.Alerts.getSSLException(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
  .....
  Caused by: java.lang.UnsupportedOperationException
          at javax.crypto.CipherSpi.engineWrap(CipherSpi.java:870)
          at javax.crypto.Cipher.wrap(Cipher.java:2417)
          at sun.security.ssl.RSAClientKeyExchange.&lt;init&gt;(Unknown Source)
          at sun.security.ssl.ClientHandshaker.serverHelloDone(Unknown Source)
          at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
          at sun.security.ssl.Handshaker.processLoop(Unknown Source)
          at sun.security.ssl.Handshaker.process_record(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
          ... 33 more
  </code></pre>
  
  <p>On checking the CipherSpi.engineWrap implementation, I see the following: </p>
  
  <pre><code>protected byte[]  engineWrap(Key key)
          throws IllegalBlockSizeException, InvalidKeyException
  
      {
          throw new UnsupportedOperationException();
      }
  </code></pre>
  
  <p>Kindly advice....</p>