-
Notifications
You must be signed in to change notification settings - Fork 10
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
Using full cert chain over single certificate #161
Conversation
CertificateFactory cf = CertificateFactory.getInstance("X.509"); | ||
File certificate = new File(certLocation, DOMAIN_CRT); | ||
if (certificate.exists()) { | ||
return cf.generateCertificates(Files.newInputStream(certificate.toPath())).toArray(new X509Certificate[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important change was to call cf.generateCertificates
here and then pass this into the CertificateEvent
and thus into Netty for initialization.
@@ -24,6 +24,7 @@ | |||
public class CertificateEvent { | |||
private final X509Certificate certificate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still required, ie. should there be a distinction between "single certificate" and "certificate chain"?
The "single certificate" code path is only used for tls-apln-01 validation, but this could also utilize the fullCertificateChain
array (just with a single entry).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah thats fair. I left it due to the CertificateEvent constructor is public so in theory someone could be using it. But yes implementation wise I could just store the full chain and in the validation cert case an array of 1 instead of 2 objects.
@zendern is there a reason this is still a draft? I would like to merge it, I see no obvious issues. |
Found that we were parsing the cert using CertificateFactory.getCertificate. This was not giving us the full chain but instead just the domain cert. Which in most places work but not in all. To address this we now will get the full chain using CertificateFactor.getCertificates and pass that on the event to Netty so that it can be used for initalization.
After rebasing I remember now. CI tests were broken but worked locally. Getting into trying to figure out why. Hoping to get it figured out this week so we can get this merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good. A couple of minor things.
acme/src/main/java/io/micronaut/acme/events/CertificateEvent.java
Outdated
Show resolved
Hide resolved
acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherMultiDomainsTaskSpec.groovy
Outdated
Show resolved
Hide resolved
acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSpec.groovy
Outdated
Show resolved
Hide resolved
.../test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskTlsApln01ChallengeSpec.groovy
Outdated
Show resolved
Hide resolved
...src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskHttp01ChallengeSpec.groovy
Outdated
Show resolved
Hide resolved
...src/test/groovy/io/micronaut/acme/challenges/AcmeCertRefresherTaskHttp01ChallengeSpec.groovy
Outdated
Show resolved
Hide resolved
acme/src/test/groovy/io/micronaut/acme/AcmeCertWildcardRefresherTaskSpec.groovy
Outdated
Show resolved
Hide resolved
acme/src/test/groovy/io/micronaut/acme/AcmeCertWildcardRefresherTaskSpec.groovy
Outdated
Show resolved
Hide resolved
@@ -278,7 +303,7 @@ private boolean writeCombinedFile(Certificate certificate) { | |||
try (BufferedWriter writer = Files.newBufferedWriter(domainCsr.toPath(), WRITE, CREATE, TRUNCATE_EXISTING)) { | |||
certificate.writeCertificate(writer); | |||
} | |||
eventPublisher.publishEvent(new CertificateEvent(getCurrentCertificate(), domainKeyPair, false)); | |||
eventPublisher.publishEvent(new CertificateEvent(domainKeyPair, false, getFullCertificateChain())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if getFullCertificateChain returns an empty array, should we publish the event?. Since CertificateEvent
assumes a non empty array due to CertificateEvent::getCert
where it gets the first certificate in the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved via 6a5dd44
@@ -482,7 +507,7 @@ private void doChallengeSpecificSetup(Authorization auth, Challenge challenge) t | |||
* Setup the certificate that has been saved to disk and configures it for use. | |||
*/ | |||
public void setupCurrentCertificate() { | |||
eventPublisher.publishEvent(new CertificateEvent(getCurrentCertificate(), getDomainKeyPair(), false)); | |||
eventPublisher.publishEvent(new CertificateEvent(getDomainKeyPair(), false, getFullCertificateChain())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if getFullCertificateChain returns an empty array, should we publish the event?. Since CertificateEvent
assumes a non empty array due to CertificateEvent::getCert
where it gets the first certificate in the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved via 6a5dd44
Can we try this build again? I'd really love to have this merged soon. |
I think the sonar CI is just broken. we can ignore it for the merge |
OK - who can do the merge @yawkat? |
just waiting for sergio to re-review this. I will handle the rest. |
I am receiving an exception now when trying |
Same issue with MN-ACME |
Fixes #156 and #73
Found that we were parsing the cert using
CertificateFactory.getCertificate. This was not giving us the full chain
but instead just the domain cert. Which in most places work but not in
all.
To address this we now will get the full chain using
CertificateFactor.getCertificates and pass that on the event to Netty so
that it can be used for initialization.