Print Decoded Data after SSLEngine Handshake is FINISHED
Asked Answered
R

0

7

How do I get the decoded data after the SSL Handshake is complete?

At the moment it seems to decrypt just some of the data.

Steps to reproduce

  1. Save and Run this code
  2. Go to https://localhost:1500 - You should notice the beginning and end of the request has something like:

?GET ... #$?+{???u7Y???

Resht answered 1/6, 2015 at 9:17 Comment(7)
While a link to the full code can be useful, could you also include (a) the relevant section of code with enough context to understand it (e.g., what is the type of sc), and (b) a description of what "get stuck" means, including a stack trace if you have one.Stayathome
Your code does not even work as described (JDK8): Https Server started in 114ms. java.nio.channels.WritePendingException at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:352) at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:387) at Test.doHandshake(Test.java:112) at Test.access$12(Test.java:106) at Test$1.completed(Test.java:75) at Test$1.completed(Test.java:1) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)Onieonion
@SkateScout: Works for me. I'm using this run command: /home/myuser/Desktop/Stuff/Test/WebServers; JAVA_HOME=/opt/java/jdk1.8.0_40 /usr/local/netbeans-8.0.2/java/maven/bin/mvn "-Dexec.args=-classpath %classpath com.webservers.HttpsServer" -Dexec.executable=/opt/java/jdk1.8.0_40/bin/java -Dexec.classpathScope=runtime org.codehaus.mojo:exec-maven-plugin:1.2.1:execResht
I think you should read the SSLEngine Dokumentation carefully. Line 54 - 62 : Should be done outside the loop Line 114 : write to Socket even if there is some outstanding write -> This can throw an exception Line 197 : allocate always new buffer Line 182 : write "Response" before read the request Line 202 : Wait up over one hour Line 206 : Print output even if there was no bytes produced by the engine Line 209 : Ignores Buffer OverflowOnieonion
@SkateScout: I've applied most of your above recommendations. I'll be honest, I don't get some of the others though. Would you care enough to add a pull request or answer by any chance?Resht
Looks like very bad thing in your code: request = Charset.defaultCharset().decode(inputBuffer).toString();. Here should be explicitly specified needed charset. This could lead to your problem.Buck
Also the problem can not be reproducedBuck

© 2022 - 2024 — McMap. All rights reserved.