小编hub*_*ert的帖子

Retrofit不支持CLEARTEXT通信

我正在尝试使用Retrofit连接到android上的https服务器.这是我的OkHttpClient

@Provides
public OkHttpClient provideContactClient(){
  HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
  ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
      .tlsVersions(TlsVersion.TLS_1_2)
      .cipherSuites(CipherSuite.TLS_RSA_WITH_DES_CBC_SHA,
          CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256,
          CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
      .build();
  interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
  SSLSocketFactory sslSocketFactory = null;
  try {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, null, null);
    sslSocketFactory = sslContext.getSocketFactory();
  }catch (GeneralSecurityException e){
    e.printStackTrace();
  }
  return new OkHttpClient.Builder()
      .addInterceptor(interceptor)
      .connectionSpecs(Collections.singletonList(spec))
      .sslSocketFactory(sslSocketFactory)
      .authenticator(new Authenticator() {
        @Override
        public Request authenticate(Route route, Response response) throws IOException {
          if(responseCount(response) >= 5){
            return null;
          }
          String credential = Credentials.basic("user", "pass");
          return response.request().newBuilder().header("Authorization", credential).build();
        }
      })
      .build();
} …
Run Code Online (Sandbox Code Playgroud)

ssl android http retrofit

23
推荐指数
3
解决办法
2万
查看次数

ScanResult功能解读

我想分析ScanResult的功能字符串.但是,这些名称最多可分为四个方括号,例如

[WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP-CCMP][WPS][ESS]
Run Code Online (Sandbox Code Playgroud)

是否有某种文档描述了哪些括号与什么相关,考虑到某些名称可能出现在各种括号中.如果某个地方的所有可能的功能列表也会很棒.

android android-wifi

9
推荐指数
2
解决办法
8946
查看次数

Android - 查看wifi密码是否正确

我打算制作一个应用程序来检查某个 wifi 网络是否使用通用密码。我有一个最常见的密码列表,但具有以下功能:

public boolean connectTo(String psKey){
    WifiConfiguration wc = new WifiConfiguration();
    wc.SSID = "\"" + dbw.getSsid() + "\"";
    wc.preSharedKey  = "\"" + psKey + "\"";

    wc.status = WifiConfiguration.Status.ENABLED;   
    wc = configureCapabs(wc, dbw.getCapability());

    int res = wifi.addNetwork(wc);
    Toast.makeText(this, "add Network returned " + res , Toast.LENGTH_SHORT).show();
    boolean b = wifi.enableNetwork(res, true);        
    Toast.makeText(this, "enableNetwork returned " + b , Toast.LENGTH_SHORT).show();
    if(!b) return false;
    boolean fin = /*b ? wifi.reassociate() : */wifi.reconnect();
    return fin;
}
Run Code Online (Sandbox Code Playgroud)

它返回真,即使密码不正确。有没有办法检查我尝试登录的密码是被接受还是被拒绝?

android wifi

4
推荐指数
1
解决办法
6487
查看次数

标签 统计

android ×3

android-wifi ×1

http ×1

retrofit ×1

ssl ×1

wifi ×1