Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

证书链模式下Auth Key校验失败 #99

Open
Don-Lee opened this issue Jun 11, 2022 · 3 comments
Open

证书链模式下Auth Key校验失败 #99

Don-Lee opened this issue Jun 11, 2022 · 3 comments

Comments

@Don-Lee
Copy link

Don-Lee commented Jun 11, 2022

华为手机上ASK 为证书链格式,当使用证书中解析出的ASK 公钥验证Auth Key时一直返回false(使用的Demo代码进行的验签操作,非证书链格式可以通常通过)。试了几个华为手机都这样,请问是什么原因?

ASK:
{"certs":["-----BEGIN CERTIFICATE-----\nMIIEVDCCAz6gAwIBAgIBATALBgkqhkiG9w0BAQswHTEbMBkGA1UEAxMSSHVhd2Vp\nIEtleVN0b3JlICAgMB4XDTIyMDYwOTEwNDgxN1oXDTMyMDYwOTEwNDgxN1owGjEY\nMBYGA1UEAxMPQSBLZXltYXN0ZXIgS2V5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\nMIIBCgKCAQEAov3uYrIsQ7ytuPR/tI9YOWMr9D6tua3k1V4KjvLcE7qyVx6fkV/e\nEsR/23eOX5BIn9HEXs8ckCtaA6oZ/xhfCZd0KsQ9pP+NiGAqPKWY0OaC/GL3g9Ky\nbAZIs7mGQEG1FdomCDSkIdIOp1Pz4PZ/6XHuNidkXx0pTW2Y8xEbmDFeGKhNRnv+\n9nhCNe4RoCXyfkxkK7OEaJLQZY70VuRpS+xvlFPGqH7EPtSRJ89AOeVjqUEGScVA\nI8+2QJitNTJvcy4Pp6vC9fZBHHRhAoIsrpg2KW4K+J09Wemza+hFwM9sWt55V0qf\nRJf+2B7VsfWhmT4pVTow4eKclv7a3iBNdQIDAQABo4IBpDCCAaAwCwYDVR0PBAQD\nAgAAMAgGA1UdHwQBADCCAV0GCisGAQQB1nkCAREEggFNMIIBSQIBAgoBAQIBAwoB\nAQR3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KD7TkOh74EKtwDdhpuZpNihWm59/If8NzgxOAJF/iaOJZYmXnKpgmAnyibxm1P6FvflC5lhQID0bRDe8fqnHzryKyGlG5hAd8cxgplgeUyn9JQREcmdXocn6HjwpklEY0HeNQc7p8g8nCu2cOGKBPKV4LSC0BwrlEJWAPqN95OeLTNCvoFDScGgpxRO/9gwV+RCVhytLQtFRNV4gS3ZiuMQ16L2F0qc1n3QU8pdNGUyie7eI87dc8Oj3AirnLMj412FJhqy7WDfTF71+hBl4Qle1wp+ewIDAQAB
-----END PUBLIC KEY-----","cpu_id":"HUAWEI_HWLYA_c790e04d-b0f9-4657-b78f-e6ef1a9f4ac0-9a374197","counter":81,"uid":"10919","rsa_pss_saltlen":32}

Auth key签名:
lNj896Plrn/+g4cRr2NEBPNcKLOSOU7FjeR8hOepOOsZ68hvPlKyTYIRsxhnra3yEg9yq9PI4o6tyzoCiP86FA1Ym/VMXRkYWifntWQO7lREtitRfjH18HhH7tu0Bp6i3vKBITECsyUAhRBh8INTRN0Vy2tyUQdaYq9akPzJzejQPBgEYkSJo5dq9T6WhITkq6nTRFZTxsxRAMTTsMlBLBT2yOL2u/hMn8XWDbfP3yN5zjfKhRFe+l5pOIQUdK22CUEwAHmIpycmg1ksld1KC/dF9Js9i8uhmasCROHTOh9maQztgzWRl1uHGqxQVlczMGbARnZPnpxGbISFw76n6A==

@inkzuji
Copy link

inkzuji commented Jan 6, 2024

请问这个问题你这边解决了么

@DingYong4223
Copy link

我这里也遇到同样的问题,官方没有支持么

@SniperXiaoJun
Copy link

我也遇到这个问题,已经解决。问题出在在我测试时,将签名原文【auth_key_json.txt】在从文本编辑器拷贝时,因为ide的原因,保存时修改了原文的换行符。在安卓的原文【auth_key_json.txt】中,换行符为“\n”。但是在我测试时,在ide中,保存的原文的【换行符】为【\r\n】了。

解决办法:可临时在后端验证时,调整示例代码如下,将换行符修正下(正式环境因为是网络传输,不会有此问题)
String hwAuthKeyString = (new String (hwAuthKeyJson,"utf-8"));//hwAuthKeyJson是demo中读取到的内容byte[]
hwAuthKeyString = hwAuthKeyString.replaceAll("\r\n", "\n");//换行符修正
hwAuthKeyJson= hwAuthKeyString.getBytes(StandardCharsets.UTF_8);//重新还原为byte[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants