小弟目前在跟一个项目,该项目是要写一个客户端程序基于HTTP协议来发送报文
所以我就想到用indy的idhttp控件来做,但是那边的服务端要求要导入证书来加密报文
服务端那边的人给了几个证书也发了一些说明过来,但我还是看得迷糊
说明如下:
证书使用步骤:
1、将pingan-stg.p7b,导出三个证书 bis-front-internetbank.cer 、paicrootstg.cer、paicstg.cer
2、产生keystore:
keytool -genkey -keystore "paic.keystore" -storepass 12345678 -keyalg RSA
3、产生授信证书库:
keytool -import -alias " bis-front-internetbank " -file bis-front-internetbank.cer -keystore cacerts
keytool -import -alias " paicrootstg " -file paicrootstg.cer -keystore cacerts
keytool -import -alias " paicstg " -file paicstg.cer -keystore cacerts
4、将paic.keystore 以及cacerts 放到指定目录下请问我要怎么样才能让idhttp控件跟这些证书关联起来呢?
所以我就想到用indy的idhttp控件来做,但是那边的服务端要求要导入证书来加密报文
服务端那边的人给了几个证书也发了一些说明过来,但我还是看得迷糊
说明如下:
证书使用步骤:
1、将pingan-stg.p7b,导出三个证书 bis-front-internetbank.cer 、paicrootstg.cer、paicstg.cer
2、产生keystore:
keytool -genkey -keystore "paic.keystore" -storepass 12345678 -keyalg RSA
3、产生授信证书库:
keytool -import -alias " bis-front-internetbank " -file bis-front-internetbank.cer -keystore cacerts
keytool -import -alias " paicrootstg " -file paicrootstg.cer -keystore cacerts
keytool -import -alias " paicstg " -file paicstg.cer -keystore cacerts
4、将paic.keystore 以及cacerts 放到指定目录下请问我要怎么样才能让idhttp控件跟这些证书关联起来呢?
解决方案 »
- delphi7时间判断
- 如何在dbgrid中最后一行增加一行统计
- 【to-all】2009能否让delphi再复生机?
- 保存图片后读取图片,图片显示残缺
- 拖动一个button水平移动时,好像默认有一个最小值,我这里试验为8个像素,如何只平移一个像素?
- 控件的属性的一个问题???__---在线等待!
- 一个定时调用PING.exe的程序中,如何在等待的时候少占或不占CPU??急!!!!!!
- 请问如何在olecontainer控件中加入文件(如word)文档?
- 如何在屏幕弹出的网页广告???用DELPHI做一个程序.......
- 如何更改开始菜单的"开始"两字,可以移动,隐藏,就是改不掉这两个字,哪位高手帮帮忙。
- ACCESS导出成EXCEL的奇怪问题
- 怎样将数据库里存储的图片显示出来?
FileInputStream fin = new FileInputStream("%存放路径%/server.cer");
X509Certificate certificate = (X509Certificate) certificatefactory
.generateCertificate(fin);
fin.close();
// 得到公钥
PublicKey pubK = certificate.getPublicKey();
// 初始化cipher
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, pubK);
byte[] code = Base64.decode(request.getParameter("password"));byte[] plain2 = new byte[code.length];
int ixplain2 = 0;
int ixcode2 = 0;
while ((code.length - ixcode2) > 128) {// 每128字节做一次解密
ixplain2 += cipher.doFinal(code, ixcode2, 128, plain2, ixplain2);
ixcode2 += 128;
}
ixplain2 += cipher.doFinal(code, ixcode2, code.length - ixcode2, plain2, ixplain2);
// 得到解密后的时间戳
String s2 = new String(plain2, 0, ixplain2, "UTF-8");
把一个der编码的cer文件读出来,用base64编码后再存入数据库中去。读出来的时候是base64编码的证书内容,想用openssl解析成X509内存结构体总是失败。后来发现是每隔64个字符就要换行,否则openssl就是解析不了。并且要有头尾:-----BEGIN CERTIFICATE-----和-----END CERTIFICATE-----
注:windows自带的证书查看器就能正常解析,并无上诉的问题。
PUDN這裡有一段DELPHI的代碼:你下載看看吧http://www.pudn.com/downloads10/sourcecode/windows/directx/detail42863.html