我正在尝试连接到运行godaddy 256位SSL证书的IIS6盒子,我收到错误:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)
一直试图确定可能导致这种情况的原因,但现在正在绘制空白.
这是我如何连接:
HttpsURLConnection conn;
conn = (HttpsURLConnection) (new URL(mURL)).openConnection();
conn.setConnectTimeout(20000);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
String tempString = toString(conn.getInputStream());
Run Code Online (Sandbox Code Playgroud) 我正在为拥有自签名SSL证书的服务器的客户工作.
我使用包装的OkHttp客户端使用Retrofit + CustomClient:
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(Config.BASE_URL + Config.API_VERSION)
.setClient(new CustomClient(new OkClient(), context))
.build();
Run Code Online (Sandbox Code Playgroud)
OkHttp默认支持调用自签名SSL证书服务器吗?
顺便说说.哪个客户端默认使用Retrofit?我认为这是OkHttp,但当我研究了一点时,我意识到我需要导入OkHttp依赖项
我正在尝试与具有自签名证书的https服务器通信.
我可以从.NET应用程序(使用ServicePointManager.ServerCertificateValidationCallback事件)做到这一点,从(使用allowsAnyHTTPSCertificateForHost)或Web浏览器(只需要声明的是,证书是可信的)原生的iOS应用程序.
但我不能让它在react-native应用程序中工作(在Android和iOS模拟器中都没有).
我尝试了不同的东西,但仍未成功.
我知道那里有一些类似的主题:
使用ReactNative App中的fetch API忽略自签名SSL证书的错误?
如果SSL(HTTPS)证书是反应原住民的XMLHttpRequest请求失败不是有效的
抓取在本地的反应不会工作在Android上使用SSL
从一个基于SSL服务器获取数据的问题
无法使用API调用反应本机进行
但是它们要么不包含答案要么不起作用(而且它们根本不包括android编程).搜索其他资源也没有效果.
我相信应该有一个简单的方法来使用自签名证书.我错了吗?有人知道吗(iOS和Android都有)?
我在android中使用retrofit来连接服务器.
public class ApiClient {
public static final String BASE_URL = "https://example.com/";
private static Retrofit retrofit = null;
public static Retrofit getClient() {
if (retrofit==null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的开发.服务器,我想禁用证书检查.我该如何在这段代码中实现?
错误:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚.
我为我的服务器生成了自签名证书.然后使用设置 - >安全性 - >安装将其添加到Android.
当我尝试使用应用程序连接到我的服务器时,我收到错误:
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)
据我所知,在我将证书添加到可信任之后它应该可以正常使用我的服务器,或者我可能会遗漏一些东西?这个想法是通过Android系统添加证书,不要更改应用程序代码.
顺便说一句,我OkHttpClient用于网络连接.也许我应该为https连接启用一些东西?
我将服务器迁移HTTP到了HTTPS我已经使用自签名证书发送网络请求HttpUrlConnection并且它工作但是对于图像加载它不起作用,因为我使用Glide进行图像加载.
javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚.从https URL通过滑动库加载图像
Glide.with(mContext).load(currentItem.getImage_path().replace(" ", "%20"))
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
genericViewHolder.imageView_1.setImageResource(R.drawable.image_thumbnail);
genericViewHolder.progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
genericViewHolder.progressBar.setVisibility(View.GONE);
return false;
}
}).into(genericViewHolder.imageView_1);
Run Code Online (Sandbox Code Playgroud)
我尝试使用此链接并使用GlideModule但它似乎不起作用.请帮忙.
我是android编程的新手。因此,任何帮助将不胜感激:所以我正在开发一个新项目,其中我使用 Retrofit 2.0 beta 2(Rest Client)。所发生的情况是,我用于 Web 服务的网站未经验证,并且没有 SSL 证书。谁能帮我绕过 SSL 证书检查。
我在我的 android 应用程序中使用 Okhttp3 来下载文件。我在使用 https 网址时遇到问题。
我有两个网址
String url1 = "https://cbsenet.nic.in/cbsenet/PDFDEC2014/Paper%20III/D-01-3.pdf";
String url2 = "https://www.ugcnetonline.in/question_papers/June2014_paper-II/J-02-14-II.pdf";
Run Code Online (Sandbox Code Playgroud)
url2工作正常,而对于url1,我遇到异常
线程“main”中的异常 javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径
我创建了一个示例 java 程序来演示问题
public static void main(String[] args) throws IOException {
String url1 = "https://cbsenet.nic.in/cbsenet/PDFDEC2014/Paper%20III/D-01-3.pdf";
String url2 = "https://www.ugcnetonline.in/question_papers/June2014_paper-II/J-02-14-II.pdf";
Request request = new Request.Builder()
.url(url1)
.build();
OkHttpClient client = new OkHttpClient();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试固定服务器的自签名证书.我的OkHttpClient有两个参数,第一个是ssl Socket Factory:
final TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {}
@SuppressLint("TrustAllX509TrustManager")
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}
};
// Install the all-trusting trust manager
SSLContext sslContext;
try {
sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
} catch (NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
FirebaseCrash.report(e);
return null;
}
// Create an ssl socket …Run Code Online (Sandbox Code Playgroud)