有人使用过此acme客户端https://github.com/zero11it/acme-client
它过去曾经可以工作,但现在却无法工作并抛出
it.zero11.acme.AcmeException: No challenge completed.
at it.zero11.acme.Acme.getCertificate(Acme.java:253)
如何解决挑战?
我确实浏览了代码,发现:
for (JsonNode challange:authorizationResponseJson.get(CHALLENGES_KEY)){
String challengeType = challange.get(CHALLENGE_TYPE_KEY).asText();
String token = challange.get(CHALLENGE_TOKEN_KEY).asText();
String uri = challange.get(CHALLENGE_URI_KEY).asText();
if (handleChallenge(userKey, domain, challengeListener, challengeType, token, uri)){
challengeURI = uri; // <-- null at last loop
challengeToken = token;
break;
}
}
在循环中的某个点,uri
因此不是challengeURI
,但它不为空,但在某一时刻变为空。
这是我完整的代码:
AcmeChallengeListener challengeListener = new HttpChallengeListener(authToken, subdomain, userId, domains[0], "");
Acme acme = new Acme(CA_PRODUCTION_URL, new DefaultCertificateStorage(true), true, true);
X509Certificate cert = acme.getCertificate(domains, AGREEMENT_URL, contacts, challengeListener);
KeyPair domainKey = acme.getCertificateStorage().getDomainKeyPair(domains);
PrivateKey privateKey = domainKey.getPrivate();
String fullchain = CertificateHelper.x509ToBase64PEMString(cert);
String privateKeyString = CertificateHelper.writePrivateKeyToPEMString(privateKey);