小编Nav*_* GV的帖子

CertificateException - OpenSSLX509CertificateFactory $ ParsingException

我在我的android项目中有以下代码,我连接到安全服务器.我收到了解析错误.[粘贴到下面].如果有人知道这个例外,请告诉我.提前致谢.

代码片段

CertificateFactory cf = CertificateFactory.getInstance("X.509");
InputStream caInput = new BufferedInputStream(new FileInputStream("/storage/emulated/0/cert.p12"));
Certificate ca;
try {
    ca = cf.generateCertificate(caInput);   // error at this line
    System.out.println("ca=" + ((X509Certificate) ca).getSubjectDN());
} finally {
    caInput.close();
}    
Run Code Online (Sandbox Code Playgroud)

错误

01-15 17:01:00.107: W/System.err(14932): java.security.cert.CertificateException:   com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
01-15 17:01:00.107: W/System.err(14932):    at   com.android.org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:272)
Run Code Online (Sandbox Code Playgroud)

01-15 17:01:00.107:W/System.err(14932):at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:195)

android openssl ssl-certificate

11
推荐指数
1
解决办法
9408
查看次数

在java中打印变量名和变量值的方法

String activityState = "resume";
DebugLog(activityState)

void DebugLog(String obj1) {}
Run Code Online (Sandbox Code Playgroud)

如何使DebugLog这样打印:

activityState : resume
Run Code Online (Sandbox Code Playgroud)

我曾经在调试时在很多地方写了很多print语句作为日志.我会写一些类似的陈述

System.out.println("activityState : " + activityState);
Run Code Online (Sandbox Code Playgroud)

我想要一个方法来打印变量名称和变量值.在C++中,它可以像下面这样完成:

#define dbg(x) cout<< #x <<" --> " << x << endl ;
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

提前致谢.

java

9
推荐指数
1
解决办法
1万
查看次数

在android中重用膨胀的视图

下面这段代码将相同的视图膨胀20次.膨胀是昂贵的.我想只给它充气一次,对20个项目使用相同的视图,我只想更改UI中的可见数据.

LinearLayout ll = new LinearLayout(context); 
for (int i = 0; i < 20; ++i) {
    View itemView = inflater.inflate(getLayoutId(), parent, false);
    itemView.setText(data.getName(i);
    ll.add(itemView);
}
Run Code Online (Sandbox Code Playgroud)

我想要这样的东西.

LinearLayout ll = new LinearLayout(context); 
View itemView = inflater.inflate(getLayoutId(), parent, false);
for (int i = 0; i < 20; ++i) {
    itemView.setText(data.getName(i);
    ll.add(itemView);
}
Run Code Online (Sandbox Code Playgroud)

但我无法以这种方式使用itemView obj.

任何人都可以告诉我如何在充气后多次使用该视图.

android android-layout

7
推荐指数
1
解决办法
3240
查看次数

连接将在 Http/2 中保持多长时间

连接将在 Http/2 中保持多长时间?我了解 Http/2 每个域使用一个连接并进行多路复用。但我没有得到有关连接将保持多长时间的任何信息。

https networking http keep-alive ttl

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