bouncycastle android,Android和BouncyCastle的IllegalAccessError

|

我正在尝试实现时间戳请求,如下所示:

http://bouncy-castle.1462172.n4.nabble.com/Timestamp-request-and-response-td1558231.html

在j2se中,它工作正常,但是在android上,我收到IllegalAccessError。

Logcat输出:

致命异常:主要

java.lang.IllegalAccessError: tried to access method org.bouncycastle.asn1.DERBoolean.:(Z)V from class org.bouncycastle.tsp.TimeStampRequestGenerator

at org.bouncycastle.tsp.TimeStampRequestGenerator.setCertReq(Unknown Source)

at org.ats.ats.onCreate(ats.java:30)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)

at android.app.ActivityThread.access$2300(ActivityThread.java:125)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)

at android.os.Handler.dispatchMessage(Handler.java:99)

at android.os.Looper.loop(Looper.java:123)

at android.app.ActivityThread.main(ActivityThread.java:4627)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:521)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

at dalvik.system.NativeStart.main(Native Method)

W/ActivityManager( 59): Force finishing activity org.ats/.ats

我有必要在TSResponse中索取证书。

Android API是2.2

我的代码:

TimeStampRequestGenerator reqgen = new TimeStampRequestGenerator();

reqgen.setCertReq(true);

MessageDigest messageDigest = MessageDigest.getInstance(\"SHA-1\");

messageDigest.update(\"messageImprint\".getBytes());

byte[] digest = messageDigest.digest();

String ocspUrl = \"http://egtstamp.egroup.hu:80/tsa\";

OutputStream out = null;

TimeStampRequest req = reqgen.generate(TSPAlgorithms.SHA1, digest);

byte request[] = req.getEncoded();

URL url = new URL(ocspUrl);

HttpURLConnection con = (HttpURLConnection) url.openConnection();

con.setDoOutput(true);

con.setDoInput(true);

con.setRequestMethod(\"POST\");

con.setRequestProperty(\"Content-type\", \"application/timestamp-query\");

con.setRequestProperty(\"Content-length\", String.valueOf(request.length));

out = con.getOutputStream();

out.write(request);

out.flush();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值