让我们加密

时间:2019-05-21 16:26:28

标签: java lets-encrypt

有人使用过此acme客户端https://github.com/zero11it/acme-client

它过去曾经可以工作,但现在却无法工作并抛出

it.zero11.acme.AcmeException: No challenge completed.
    at it.zero11.acme.Acme.getCertificate(Acme.java:253)

来自Git的实际代码在https://github.com/zero11it/acme-client/blob/42af8c2c06ea481838a545dc90de8dfef945ca4a/src/main/java/it/zero11/acme/Acme.java#L252

如何解决挑战?

我确实浏览了代码,发现:

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);

0 个答案:

没有答案