Closed seveniruby closed 8 years ago
The site you're visiting, https://124.250.3.102, presents a certificate issued for xueqiu.com and .xueqiu.com. You can either make the request using a .xueqiu.com domain that resolves to that IP address, or you can disable hostname verification completely using the setTrustAllServers(true) method.
thank you for the reply. i already use the setTrustAllServers(true) it can't work i also add this
val verifier = new javax.net.ssl.HostnameVerifier() {
def verify(hostname: String, session: javax. net.ssl.SSLSession): Boolean = {
log.info(hostname)
return true
}
}
javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(verifier)
it can't work too
also i can't use hostname to replace the ip. because sometime i need use same hostname but different ip for multi environments
for recording requests base on bmp, i use burpsuite and set upsteam proxy to bmp , it works if only use bmp, it's not work
If you can't use the hostname, then server certificate validation will fail. The server, xueqiu.com, is returning a certificate for *.xueqiu.com, not for an IP address. There is simply no way to make that work. One possible work-around would be to modify your /etc/hosts file.
Alternatively, you can bypass validation completely by setting trustAllServers to true (that line is commented out in your code snippet). That will definitely work, just make sure you're using the latest version of BMP.
i create two cases , one for bmp and one for little proxy i found that only the little proxy can work this is demo code
package com.xueqiu.httpapi.framework
import java.net.InetSocketAddress
import com.fasterxml.jackson.databind.{SerializationFeature, ObjectMapper}
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.http.{HttpResponse, HttpObject, HttpRequest}
import net.lightbody.bmp.BrowserMobProxyServerLegacyAdapter
import net.lightbody.bmp.filters.RequestFilter
import net.lightbody.bmp.util.{HttpMessageInfo, HttpMessageContents}
import org.littleshoot.proxy.{HttpFiltersAdapter, HttpFilters, HttpFiltersSourceAdapter, HttpFiltersSource}
import org.littleshoot.proxy.impl.DefaultHttpProxyServer
import net.lightbody.bmp.BrowserMobProxyServer
import net.lightbody.bmp.proxy.LegacyProxyServer
import org.scalatest.FunSuite
/**
* Created by seveniruby on 16/9/7.
*/
class TestProxyServer extends FunSuite with CommonLog{
test("proxy server bmp"){
val proxy=new BrowserMobProxyServer
//val proxy=new BrowserMobProxyServerLegacyAdapter()
proxy.setTrustAllServers(true)
proxy.start(7777)
proxy.newHar()
val requestFilter = new RequestFilter {
override def filterRequest(request: HttpRequest, contents: HttpMessageContents, messageInfo: HttpMessageInfo): HttpResponse = {
//request.headers().set("accept-encoding", "deflate, br")
log.info(request.getUri)
return null
}
}
proxy.addRequestFilter(requestFilter)
Thread.sleep(2000000)
}
test("little proxy"){
val filter=new HttpFiltersSourceAdapter(){
override def filterRequest(originalRequest: HttpRequest , ctx: ChannelHandlerContext ): HttpFilters={
return new HttpFiltersAdapter(originalRequest) {
override def clientToProxyRequest(httpObject: HttpObject ):HttpResponse= {
// TODO: implement your filtering here
log.info(originalRequest.getUri)
return null;
}
override def serverToProxyResponse(httpObject: HttpObject ):HttpObject= {
// TODO: implement your filtering here
return httpObject;
}
};
}
}
val proxy=DefaultHttpProxyServer.bootstrap()
.withAddress(new InetSocketAddress("0.0.0.0", 7777))
//.withPort(7777)
.withFiltersSource(filter)
.start()
Thread.sleep(2000000)
}
}
the result of little proxy
Testing started at 下午1:12 ...
0 [ScalaTest-run-running-TestProxyServer] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Starting proxy at address: /0.0.0.0:7777
49 [ScalaTest-run-running-TestProxyServer] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Proxy listening with TCP transport
336 [ScalaTest-run-running-TestProxyServer] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Proxy started at address: /0:0:0:0:0:0:0:0:7777
2016-09-07 13:12:25 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] data.flurry.com:443
2016-09-07 13:12:37 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] http://oc.umeng.com/check_config_update
2016-09-07 13:12:38 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] http://oc.umeng.com/check_config_update
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 101.201.62.21:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 101.201.62.21:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 101.201.62.21:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 124.250.3.101:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] api.xueqiu.com:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 124.250.3.101:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 124.250.3.101:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] http://alog.umeng.com/app_logs
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 101.201.62.21:443
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] http://alog.umeng.com/app_logs
2016-09-07 13:12:41 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] http://alog.umeng.com/app_logs
2016-09-07 13:12:44 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 101.201.62.21:443
2016-09-07 13:12:46 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] 101.201.62.21:443
2016-09-07 13:12:50 INFO [TestProxyServer$$anonfun$2$$anon$1$$anon$2.clientToProxyRequest.$F.49] data.flurry.com:443
the result of bmp
Testing started at 下午1:13 ...
0 [ScalaTest-run-running-TestProxyServer] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Starting proxy at address: 0.0.0.0/0.0.0.0:7777
34 [ScalaTest-run-running-TestProxyServer] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Proxy listening with TCP transport
190 [ScalaTest-run-running-TestProxyServer] INFO org.littleshoot.proxy.impl.DefaultHttpProxyServer - Proxy started at address: /0:0:0:0:0:0:0:0:7777
2016-09-07 13:13:54 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] data.flurry.com:443
4696 [LittleProxy-0-ClientToProxyWorker-0] WARN net.lightbody.bmp.mitm.util.SslUtil - Disabling upstream server certificate verification. This will allow attackers to intercept communications with upstream servers.
2016-09-07 13:13:58 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] http://oc.umeng.com/check_config_update
2016-09-07 13:14:01 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.21:443
2016-09-07 13:14:01 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.24:443
2016-09-07 13:14:01 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.24:443
2016-09-07 13:14:01 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 124.250.3.101:443
2016-09-07 13:14:01 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] api.xueqiu.com:443
2016-09-07 13:14:03 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 124.250.3.101:443
2016-09-07 13:14:03 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 124.250.3.101:443
2016-09-07 13:14:03 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] /jspatch/config.json?app_key=02dfc0390c04c8e8464e0b2d13c5cfcb&app_version=8.4-rc-1460&user_data=%7B%22user_id%22%3A9001459498%2C%22device%22%3A%22Genymotion_Google_Nexus_4_-_4.4.4_-_API_19_-_768x1280%22%2C%22system_version%22%3A%224.4.4%22%2C%22channel_id%22%3A%22xueqiu%22%2C%22user_verify_type%22%3A0%7D
2016-09-07 13:14:03 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 124.250.3.101:443
2016-09-07 13:14:03 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.24:443
2016-09-07 13:14:03 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.23:443
2016-09-07 13:14:04 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.21:443
2016-09-07 13:14:04 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.24:443
14569 [LittleProxy-0-ClientToProxyWorker-2] INFO org.littleshoot.proxy.impl.ClientToProxyConnection - (NEGOTIATING_CONNECT) [id: 0x54797cbc, L:/192.168.57.1:7777 - R:/192.168.57.101:56421]: An IOException occurred on ClientToProxyConnection: Connection reset by peer
14623 [LittleProxy-0-ProxyToServerWorker-2] INFO org.littleshoot.proxy.impl.ProxyToServerConnection - (DISCONNECTED) [id: 0x346e8281, L:0.0.0.0/0.0.0.0:52717]: Connection to upstream server failed
java.nio.channels.ClosedChannelException
at io.netty.handler.ssl.SslHandler.channelInactive(...)(Unknown Source)
2016-09-07 13:14:06 INFO [TestProxyServer$$anonfun$1$$anon$3.filterRequest.$F.34] 101.201.62.25:443
i have update my demo code and this is the demo app http://xqfile.imedao.com/android-release/xueqiu_832_08181340.apk
2016-07-19 20:49 GMT+08:00 Jason Hoetger notifications@github.com:
Closed #493 https://github.com/lightbody/browsermob-proxy/issues/493.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lightbody/browsermob-proxy/issues/493#event-727476782, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKocXpA6HWkiOV0kdlbqecAGcPEX8KIks5qXMfBgaJpZM4JF1KQ .
my proxyServer config
when i use this command, i get a 502 error message
the bmp error log (not debug) was
so how can i avoid the error