Detach DN 反转问题

This commit is contained in:
cheney 2022-08-18 18:25:22 +08:00
parent 748571082b
commit d8b40a51b5
3 changed files with 12 additions and 12 deletions

View File

@ -78,7 +78,8 @@
{ {
"func": "zip", "func": "zip",
"from": "%out_path%/*", "from": "%out_path%/*",
"to": "%out_path%/sydapi-%version%.%project.git_commit_hash%.zip" "to": "%out_path%/sydapi-%version%.%project.git_commit_hash%.zip",
"vc" : "18M"
}, },
{ {
"func": "open", "func": "open",

View File

@ -24,7 +24,7 @@ public class TestHT {
public void before() { public void before() {
// 通过设置debug的属性开启debug如果不设置则默认不打开 // 通过设置debug的属性开启debug如果不设置则默认不打开
System.setProperty("com.sunyard.sydapi4j.debug", "true"); System.setProperty("com.sunyard.sydapi4j.debug", "true");
api = (SydApi4j) new SydApi4j().connect("192.168.0.200", 8889, null, 1000); api = (SydApi4j) new SydApi4j().connect("172.16.18.59", 8889, null, 1000);
} }
@After @After
@ -107,32 +107,31 @@ public class TestHT {
String orgData = "111111213323143243243"; String orgData = "111111213323143243243";
String sign = api.attachedSign(orgData.getBytes(), dn); String sign = api.detachedSign(1, orgData.getBytes(), dn);
System.out.println("签名结果: " + sign); System.out.println("签名结果: " + sign);
System.out.println("签名结果 hex : " + Util.bytes2HexString(Util.decodeBase64(sign))); System.out.println("签名结果 hex : " + Util.bytes2HexString(Util.decodeBase64(sign)));
boolean verify = api.attachedVerify(sign); boolean verify = api.detachedVerify(1, orgData.getBytes(), sign);
System.out.println("验签结果: " + verify); System.out.println("验签结果: " + verify);
Assert.assertTrue(verify); Assert.assertTrue(verify);
} }
@Test @Test
public void testDetachedSignAndVerify2() throws UnsupportedEncodingException { public void testDetachedSignAndVerify2() throws UnsupportedEncodingException {
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1"; // Dn 反转问题
String dn = "CN=YCCA@黄金交易所@Zhuangj@1,OU=Individual-2,OU=YCCA,O=CFCA OCA1,C=CN";
String orgData = "111111213323143243243"; String orgData = "111111213323143243243";
String sign = api.attachedSignSoft(orgData.getBytes(), dn); String sign = api.detachedSign(1, orgData.getBytes(), dn);
System.out.println("签名结果: " + sign); System.out.println("签名结果: " + sign);
System.out.println("签名结果 hex: " + Util.bytes2HexString(Util.decodeBase64(sign))); System.out.println("签名结果 hex : " + Util.bytes2HexString(Util.decodeBase64(sign)));
boolean verify = api.attachedVerify(sign); boolean verify = api.detachedVerify(1, orgData.getBytes(), sign);
System.out.println("验签结果: " + verify); System.out.println("验签结果: " + verify);
Assert.assertTrue(verify); Assert.assertTrue(verify);
} }
@Test @Test
public void testDetachedSignAndVerify3() throws UnsupportedEncodingException { public void testDetachedSignAndVerify3() throws UnsupportedEncodingException {
String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1"; String dn = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";

View File

@ -1,4 +1,4 @@
package com.sunyard.sydapi.sample; package com.sunyard.sydapi.test;
import com.sunyard.SydApi; import com.sunyard.SydApi;
@ -15,7 +15,7 @@ public class TestPKCS7 {
// 连接加密机 // 连接加密机
// SydApi4j api = (SydApi4j) new SydApi4j().connect("172.16.17.162", 8889, null, 1000); // SydApi4j api = (SydApi4j) new SydApi4j().connect("172.16.17.162", 8889, null, 1000);
SydApi4j.SYD_Set_Parameter_HA("unkown", "192.168.0.100", 8889, 1000); SydApi4j.SYD_Set_Parameter_HA("unkown", "172.16.18.59", 8889, 1000);
SydApi4j api = (SydApi4j) new SydApi4j(); SydApi4j api = (SydApi4j) new SydApi4j();
try { try {