Skip to content

Conversation

@ruben-haegeman
Copy link

@ruben-haegeman ruben-haegeman commented Oct 7, 2020

While generating a wildcard certificate 2 challenges will be deployed for the same domain.
One challenge is deployed to verify domain.tld and one is deployed for *.domain.tld. Both however will be deployed to the domein _acme_challenge.domain.tld

This fix makes it possible for multiple challenges to exist at the same time for the same domain.

This PR closes issue #8

PS: I'm not fluent in bash so feedback is always welcome.

@ruben-haegeman ruben-haegeman force-pushed the feature/wildcard-support branch from 21e77b1 to 8692114 Compare October 7, 2020 14:32
@ruben-haegeman ruben-haegeman force-pushed the feature/wildcard-support branch from 8692114 to 50dbe71 Compare October 7, 2020 14:35
@ruben-haegeman
Copy link
Author

@fogs
No idea if I should tag you or not.

Copy link
Contributor

@fogs fogs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ruben,

Thanks for submitting your PR. I have added some comments to it, please have a look!

Keep up the good work,
fogs

# The domain name (CN or subject alternative name) being
# validated.
# - TOKEN_FILENAME
# The name of the file is irrelevant for the DNS challenge, yet still provided
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that spaces at the end of the line are crap, sorry for my poor code quality!

But can we please have a separate commit when removing those?

# Remove old txt token
gcloud dns record-sets transaction start --zone $zonename
gcloud dns record-sets transaction remove --name $existingName --type TXT --ttl $existingTtl --zone $zonename -- "$existingRrdata"
gcloud dns record-sets transaction execute --zone $zonename --format='value(id)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to perform a transaction execute here and a transaction start in line 59? Or can we also handle that all in one transaction?

if [ "$existingName" == "_acme-challenge.$DOMAIN." ]; then
gcloud dns record-sets transaction remove --name $existingName --type TXT --ttl $existingTtl --zone $zonename -- "$existingRrdata"
# Remove old txt token
gcloud dns record-sets transaction start --zone $zonename
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this transaction start pulled into the IF statement?

# nsresult comes with the TXT RR in double quotes - remove those
nsresult=${nsresult//$'"'/''}
until [[ "$nsresult" = "$TOKEN_VALUE" ]]; do
until [[ "$nsresult" == *"$TOKEN_VALUE"* ]]; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between the old version and the new? Won't * expand in bash?


gcloud dns record-sets transaction remove --name $existingName --type TXT --ttl $existingTtl --zone $zonename -- "$existingRrdata"
gcloud dns record-sets transaction execute --zone $zonename
existingRecord=`gcloud dns record-sets list --name "_acme-challenge.$DOMAIN." --type TXT --zone $zonename --format='value(name,rrdatas,ttl)'`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why rrdatas instead of the previously used rrdatas[0]?

# Remove all record
gcloud dns record-sets transaction start --zone $zonename
stringify=${existingRrdata[@]}
stringify=${stringify// /"\" \""}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is adding another tool requirement to the script - is there no way we can do that in bash? Also, please name variables according to what is in there instead of naming them after the command you got the data from.

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

Successfully merging this pull request may close these issues.

2 participants