Send/Get Requests/Responses using both HTTP and HTTPS. Version 1.0.0-beta7

314 views
Skip to first unread message

Santiago

unread,
Oct 28, 2014, 9:52:42 AM10/28/14
to littl...@googlegroups.com
Hi!

I searched the forum and didn't found the solution to my issue. I want
to be able to send/get requests/responses using both HTTP and HTTPS.
This are the steps I have tested so far.

  - Listen to a port in my local machine. Example: localhost:15000.
                This is easy. Define in my proxy the port 15000.
(.withPort(15000))

                 DefaultHttpProxyServer.bootstrap()
       .withPort(15000)

 - When a request is captured, for example with the url
http:\\localhost:15000\app, I want to send this request at other
server making use of HTTPS protocol. For example:
https:\\url:8755\app1. The same way, when the server response
(https:\\url:8755\app1), the response must arrive to the client,  (
http:\\localhost:15000\app).

                 I don't know how to proceed further. I have tried a
couple of things, my steps were:

                  1. Create a Filter

                      HttpFiltersSource filtersSource2 = new
HttpFiltersSourceAdapter() {
             @Override
               public HttpFilters filterRequest(HttpRequest originalRequest) {
                   return new HttpFiltersAdapter(originalRequest) {
                   @Override
                   public HttpResponse requestPre(HttpObject httpObject) {
                       if (httpObject instanceof HttpRequest) {
                           HttpRequest req = (HttpRequest) httpObject;
                           req.headers().set("Host", "url:87755");
                       }
                       return null;
                   }
               };
           }
         };

If I do this, the comunication between client and server works
perfectly using HTTP protocol.

Next I tried to improve the server to support HTTPS also.

                 2. Define the server as ManInTheMiddle
                     .withManInTheMiddle(new MyClassCertificateMng()).

                      The class MyClassCertificateMng is:

                       public class MyClassCertificateMng implements
MitmManager {
                  MyClassCertificate selfSignedSslEngineSource =
                                  new MyClassCertificate(true);

                        public SSLEngine serverSslEngine() {
                                      return
selfSignedSslEngineSource.newSslEngine();
                           }

                      public SSLEngine clientSslEngineFor(SSLSession
serverSslSession) {
                                    return
selfSignedSslEngineSource.newSslEngine();
                           }

                     NOTE: The class MyClassCertificate is a copy of
class SelfSignedSslEngineSource, I have only changed the name of
keystore and his pass.

And now I don't know what are the next steps. Any idea of what should
I try next?

Jeryl Cook

unread,
Feb 12, 2015, 5:11:01 PM2/12/15
to littl...@googlegroups.com
Having the same issue, did you resolve this?
Reply all
Reply to author
Forward
0 new messages