1 Reply Latest reply: Apr 5, 2013 4:51 PM by 875275 RSS

    javax.net.ssl.SSLException: Received fatal alert: bad_record_ma

    875275
      Hi,

      I am trying to using HttpsURLConnection to open https URL: https://www.mycompany.com/myapps/myFile?username=&password. My java class sits on Apache2/tomcat6, and https is on another machine with different domain. Https URL returns XML. It does not require any private cert from me.


      First, I tried to export certificate from www.mycompany.com and load it to keystore using keytool, however, I got javax.net.ssl.SSLException: Received fatal alert: bad_record_ma.

      Seconcd, in my class, I tried to open the link without using certificate from mycompany.com, and then I got the same error.

      BTW, my java version is 1.6.

      Please help. thank you in advance.

      jfu

      --------------------------------------------------------

      javax.net.ssl.SSLException: Received fatal alert: bad_record_mac
           at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190)
           at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
           at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1682)
           at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:932)
           at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
           at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1139)
           at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1123)
           at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:418)
           at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
           at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1041)
           at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
           at com.mcps.hydra.actions.LoginAction.execute(LoginAction.java:182)
           at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
           at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
           at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
           at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
           at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)

      ----------------- Here is my source code ----------------------------------
      String urllink = https://www.mycompany.com/myapps/myFile?username=&password";

      Url url=new URL(urllink);

      HttpsURLConnection con = (HttpsURLConnection) url.openConnection();

      con.setDoInput(true);
      con.setDoOutput(true);
      con.setRequestMethod( "POST" );
      con.setRequestProperty( "Content-Type", "application/xml" );

      BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); // this is the line that error is thrown

      while ( (inputLine = in.readLine()) != null)
      {
      writerXML.write(inputLine);
      writerXML.newLine();
      }
        • 1. Re: javax.net.ssl.SSLException: Received fatal alert: bad_record_ma
          875275
          more information.

          https://www.mycompay.com is sitting on tomcat6 server, where /myapps/myFile?username=&password= sits on another domanin on another machine.

          If I use HttpsURLconnection.open("http://anotherdomain.com/myapps/myFile?username=&password="), I can get the result back; if I use HttpsURLconnection.open("https://www.mycompay.com /myapps/myFile?username=&password="), I got the error I mentioned.

          any idea?

          Thank you,

          jfu