我们已经解压缩了 adhaar 二维码示例数据,我们能够验证手机号码和电子邮件,但我们停留在 Pdf 文档下面的最后一步,我们无法使用签名和证书验证签名数据,我们已经尝试使用 uidai 的两个证书已在开发者部分现场提供。
Uidai 文件如下: https://uidai.gov.in/images/resource/User_manulal_QR_Code_15032019.pdf
如果有人对此进行过工作,请提供帮助。
验证码如下:
public static boolean validateqr(
byte[] signature, String QrCodeDataa, String public_key_path)
throws SAXException, MarshalException, XMLSignatureException, InvalidKeyException, SignatureException, UnsupportedEncodingException {
System.out.println("finalOutput=================>" + new String(output, "ISO-8859-1"));
System.out.println();
System.out.println("QrCode Data=================>" + QrCodeDataa);
System.out.println();
System.out.println("signatureData============>" + new String(signature, "ISO-8859-1"));
System.out.println();
System.out.println("public_key_path============>" + public_key_path);
System.out.println();
boolean valid = false;
try {
//byte[] signature = signatureData;
//System.out.println("signedData====>"+signedData);
FileInputStream fin = new FileInputStream(public_key_path);
CertificateFactory f = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate) f.generateCertificate(fin);
//System.out.println("certificate====>"+certificate);
Signature sign = Signature.getInstance(SHA_256_WITH_RSA);
sign.initVerify(certificate);
sign.update(QrCodeDataa.getBytes());
valid = sign.verify(signature);
} catch (InvalidKeyException | CertificateException | NoSuchAlgorithmException | IOException exp) {
System.out.println("Error Occured Please Contact Your Administrator");
exp.printStackTrace();
}
return valid;
}