我正在尝试连接到运行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) 我正在尝试使用此代码发出https请求:
RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
request = new Request<String>(Request.Method.GET,"https://devblahblahblah.com/service/etc",errListener);
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误:
com.android.volley.NoConnectionError:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚.
有两点需要注意:
我实际上需要知道Android Volley框架中是否有任何交换机/选项,我将成功点击HTTPS URL?
在我的服务器(生产服务器)中,我有一个goDaddy ssl证书.我有iOS和Android应用程序连接服务器,iOS连接没有问题,Android连接版本4.*一切都很好,但设备2.3.*我总是得到SSLHandshakeException.
我确实喜欢Android开发者页面(https://developer.android.com/training/articles/security-ssl.html).
我已经在stackoverflow中看到了类似的线程(这里),但没有人帮忙.
然后我看到这个线程谈论扩展密钥用法,但在调试时我得到以下信息:
[2]: OID: 2.5.29.37, Critical: false
Extended Key Usage: [ "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2" ]
Run Code Online (Sandbox Code Playgroud)
所以我猜证书不是"强制"扩展密钥用法.
同样在此线程有一些其他可能的原因,如日期/时间是完全地错了,至极都是不存在的.
考虑到这一点,我现在不知道问题可能在哪里.
有什么建议?
编辑: StackTrace如下:
08-04 16:54:30.139: W/System.err(4832): Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-04 16:54:30.149: W/System.err(4832): at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:161)
08-04 16:54:30.149: W/System.err(4832): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:664)
08-04 16:54:30.149: W/System.err(4832): at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
08-04 16:54:30.159: W/System.err(4832): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:474)
Run Code Online (Sandbox Code Playgroud) 我有一个Android应用程序连接到我们托管的SSL Web服务.Web服务器是apache,它有我们自己创建的CA和自签名SSL证书.
我已将我们的CA证书导入安卓中的用户可信证书部分的Android平板电脑上.
我已经测试了对Web服务器的访问,并且可以确认Web服务证书显示为有效(下面的屏幕截图)

以下是安全设置中的证书:

现在,当我尝试访问应用程序中的Web服务时,我会触发"无对等证书"异常.
这是简化的SSL实现:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// allows network on main thread (temp hack)
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
SchemeRegistry schemeRegistry = new SchemeRegistry();
//schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
schemeRegistry.register(new Scheme("https", newSSLSocketFactory(), 443));
HttpParams params = new BasicHttpParams();
SingleClientConnManager mgr = new SingleClientConnManager(params, schemeRegistry);
HttpClient client = new DefaultHttpClient(mgr, params);
HttpPost httpRequest = new HttpPost("https://our-web-service.com");
try {
client.execute(httpRequest);
} catch (Exception e) {
e.printStackTrace(); // …Run Code Online (Sandbox Code Playgroud) 我正在使用使用自签名CA证书创建的证书运行https服务器.
现在我想将Socket.io客户端连接到连接到https服务器的Socket.io服务器.不幸的是,我收到一个错误,告诉我:
Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
at SecurePair.<anonymous> (tls.js:1271:32)
at SecurePair.EventEmitter.emit (events.js:92:17)
at SecurePair.maybeInitFinished (tls.js:883:10)
at CleartextStream.read [as _read] (tls.js:421:15)
at CleartextStream.Readable.read (_stream_readable.js:293:10)
at EncryptedStream.write [as _write] (tls.js:330:25)
at doWrite (_stream_writable.js:211:10)
at writeOrBuffer (_stream_writable.js:201:5)
at EncryptedStream.Writable.write (_stream_writable.js:172:11)
at write (_stream_readable.js:547:24)
at flow (_stream_readable.js:556:7)
Run Code Online (Sandbox Code Playgroud)
基本上,此错误告诉我无法成功验证证书.这是因为相应的CA证书是自签名的.使用https请求时,我可以指定我信任的CA.
在这种情况下如何进行Socket.io连接?
PS:我正在运行Node.js 0.10.0和Socket.io 0.9.13.
我正在尝试让我的应用通过https与我的服务器通信.由于我不想付费以获得由受信任的CA签署的服务器证书,因此解决方案是使用自签名证书.
所以,我创建了我的caconfig.cnf如下:
[ ca ]
default_ca = CA_default # The default ca section
[ CA_default ]
dir = ./demoCA # top dir
database = $dir/index.txt # index file.
new_certs_dir = $dir/newcerts # new certs dir
certificate = $dir/cacert.pem # The CA cert
serial = $dir/serial # serial no file
private_key = $dir/private/cakey.pem # CA private key
RANDFILE = $dir/private/.rand # random number file
default_days = 365 # how long to certify for
default_crl_days = 30 # how long before next …Run Code Online (Sandbox Code Playgroud)