File tree Expand file tree Collapse file tree 4 files changed +21
-22
lines changed
src/main/java/tech/httptoolkit/javaagent/advice Expand file tree Collapse file tree 4 files changed +21
-22
lines changed Original file line number Diff line number Diff line change 11package tech .httptoolkit .javaagent .advice ;
22
33import net .bytebuddy .asm .Advice ;
4- import tech .httptoolkit .javaagent .HttpProxyAgent ;
5-
64import javax .net .ssl .SSLContext ;
5+ import java .security .NoSuchAlgorithmException ;
76
87public class OverrideSslContextFieldAdvice {
98
109 @ Advice .OnMethodEnter
1110 public static void beforeMethod (
1211 @ Advice .FieldValue (value = "sslContext" , readOnly = false ) SSLContext sslContextField
13- ) {
14- sslContextField = HttpProxyAgent . getInterceptedSslContext ();
12+ ) throws NoSuchAlgorithmException {
13+ sslContextField = SSLContext . getDefault ();
1514 }
1615
1716}
Original file line number Diff line number Diff line change 11package tech .httptoolkit .javaagent .advice .apacheclient ;
22
33import net .bytebuddy .asm .Advice ;
4- import tech .httptoolkit .javaagent .HttpProxyAgent ;
54
5+ import javax .net .ssl .SSLContext ;
66import java .lang .reflect .Field ;
7+ import java .security .NoSuchAlgorithmException ;
78import java .util .Arrays ;
89
910public class ApacheSetSslSocketFactoryAdvice {
1011
1112 @ Advice .OnMethodEnter
12- public static void beforeCreateSocket (@ Advice .This Object thisFactory ) {
13+ public static void beforeCreateSocket (@ Advice .This Object thisFactory ) throws Exception {
1314 // Before creating the socket - replace the SSL context so the new socket trusts us.
1415
1516 boolean intercepted = false ;
@@ -22,12 +23,8 @@ public static void beforeCreateSocket(@Advice.This Object thisFactory) {
2223 field .setAccessible (true );
2324
2425 // Overwrite the socket factory with our own:
25- try {
26- field .set (thisFactory , HttpProxyAgent .getInterceptedSslContext ().getSocketFactory ());
27- intercepted = true ;
28- } catch (IllegalAccessException e ) {
29- throw new RuntimeException ("Could not intercept Apache HttpClient HTTPS sockets" );
30- }
26+ field .set (thisFactory , SSLContext .getDefault ().getSocketFactory ());
27+ intercepted = true ;
3128 } catch (NoSuchFieldException ignored ) { }
3229 }
3330
Original file line number Diff line number Diff line change 22
33import net .bytebuddy .asm .Advice ;
44import org .eclipse .jetty .util .ssl .SslContextFactory ;
5- import tech .httptoolkit .javaagent .HttpProxyAgent ;
5+
6+ import javax .net .ssl .SSLContext ;
67
78public class JettyReturnSslContextFactoryV10Advice {
89 @ Advice .OnMethodExit
9- public static void getSslContextFactory (@ Advice .Return (readOnly = false ) SslContextFactory .Client returnValue ) {
10+ public static void getSslContextFactory (
11+ @ Advice .Return (readOnly = false ) SslContextFactory .Client returnValue
12+ ) throws Exception {
1013 SslContextFactory .Client sslFactory = new SslContextFactory .Client ();
11- sslFactory .setSslContext (HttpProxyAgent .getInterceptedSslContext ());
12- try {
13- sslFactory .start ();
14- } catch (Exception e ) {
15- throw new RuntimeException (e );
16- }
14+ sslFactory .setSslContext (SSLContext .getDefault ());
15+ sslFactory .start ();
1716
1817 returnValue = sslFactory ;
1918 }
Original file line number Diff line number Diff line change 44import org .eclipse .jetty .util .ssl .SslContextFactory ;
55import tech .httptoolkit .javaagent .HttpProxyAgent ;
66
7+ import javax .net .ssl .SSLContext ;
8+
79public class JettyReturnSslContextFactoryV9Advice {
810
911 @ Advice .OnMethodExit
10- public static void getSslContextFactory (@ Advice .Return (readOnly = false ) SslContextFactory returnValue ) {
12+ public static void getSslContextFactory (
13+ @ Advice .Return (readOnly = false ) SslContextFactory returnValue
14+ ) throws Exception {
1115 SslContextFactory sslFactory = new JettyV9StubContextFactory ();
12- sslFactory .setSslContext (HttpProxyAgent . getInterceptedSslContext ());
16+ sslFactory .setSslContext (SSLContext . getDefault ());
1317 try {
1418 sslFactory .start ();
1519 } catch (Exception e ) {
You can’t perform that action at this time.
0 commit comments