gpt4 book ai didi

安卓 SSL 支持

转载 作者:太空宇宙 更新时间:2023-11-03 13:56:24 26 4
gpt4 key购买 nike

我正在为 Android 1.5 编写应用程序。想知道 Android 1.5 版本是否支持 128 位或其他的 SSL?

最佳答案

当然,这是一个忽略证书错误的代码:

public static String makeGETRequest(String s,String encoding)
{

DefaultHttpClient http = new DefaultHttpClient();
SSLSocketFactory ssl = (SSLSocketFactory)http.getConnectionManager().getSchemeRegistry().getScheme( "https" ).getSocketFactory();
ssl.setHostnameVerifier( SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER );

HttpResponse res;
try {

res = http.execute(new HttpGet(s));
InputStream is = res.getEntity().getContent();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);
}

return new String(baf.toByteArray(),encoding);
}
catch (ClientProtocolException e) {
// TODO Auto-generated catch block
return "error: " + e.getMessage();
}
catch (IOException e) {
// TODO Auto-generated catch block
return "error: " + e.getMessage();
}

}

关于安卓 SSL 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5500506/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com