Netcipher是一个Android库项目,它提供了多种方法来改善移动应用程序中的网络安全性. “洋葱”这个名称不仅指Tor使用的洋葱路由概念(提供匿名性和对交通监控的抵抗),还指任何应用程序应该使用的多层安全性的概念.
更具体地说,这个库提供:
1. Stronger Sockets: Through support for the right cipher suites, pinning and more, we ensure your encrypted connections are as strong as possible.
2. Proxied Connection Support: HTTP and SOCKS proxy connection support for HTTP and HTTP/S traffic through specific configuration of the Apache HTTPClient library
https://guardianproject.info/code/netcipher/
解决方法:
您需要实现自己的客户端,该客户端将在Netcipher http客户端上执行Retrofit请求.
>将请求转换为适当的Netcipher请求(复制http方法,标题,正文)
>在Netcipher http客户端上执行已翻译的请求
>获取响应并将其转换为改进响应(复制http状态代码,响应,标题)
>返回响应以反序列化为类型.
将您的客户端传递给RestAdapter.Builder.
完成.
public class NetcipherClient implements Client{
private Context mContext;
public NetcipherClient(Context context){
mContext = context;
//As far as I could see from the sample, Netcipher seems to be dependant on application `Context`.
}
@Override
public retrofit.client.Response execute(retrofit.client.Request request) throws IOException {
//Set up configuration for Netcipher (proxy, timeout etc)
// Translate Request to Netcipher request
// Execute and obtain the response
// Build Response from response
return response;
}
}