Skip to content
This repository was archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
Switch from v2_endpoint to directory
Browse files Browse the repository at this point in the history
  • Loading branch information
will-in-wi committed Apr 16, 2020
1 parent 8e60187 commit 0b23659
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions docs/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Switching to ACMEv2 broke backwards compatibility in a couple ways.

- You need to change the `endpoint` entry in your config to `v2_endpoint` and update it to staging or production.
v2_endpoint = "https://acme-staging-v02.api.letsencrypt.org/directory" # Staging
#v2_endpoint = "https://acme-v02.api.letsencrypt.org/directory" # Production
- You need to change the `endpoint` entry in your config to `directory` and update it to staging or production.
directory = "https://acme-staging-v02.api.letsencrypt.org/directory" # Staging
#directory = "https://acme-v02.api.letsencrypt.org/directory" # Production

# Upgrading from v2 to v3

Expand Down
2 changes: 1 addition & 1 deletion lib/letsencrypt_webfaction/application/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def private_key
end

def client
@_client ||= Acme::Client.new(private_key: private_key, endpoint: @options.endpoint)
@_client ||= Acme::Client.new(private_key: private_key, directory: @options.directory)
end

def register_key
Expand Down
8 changes: 4 additions & 4 deletions lib/letsencrypt_webfaction/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module LetsencryptWebfaction
class Options
NON_BLANK_FIELDS = %i[username password letsencrypt_account_email v2_endpoint api_url servername].freeze
NON_BLANK_FIELDS = %i[username password letsencrypt_account_email directory api_url servername].freeze

WEBFACTION_API_URL = 'https://api.webfaction.com/'.freeze

Expand Down Expand Up @@ -39,8 +39,8 @@ def letsencrypt_account_email
@config['letsencrypt_account_email']
end

def v2_endpoint
@config['v2_endpoint']
def directory
@config['directory']
end

def api_url
Expand All @@ -57,7 +57,7 @@ def certificates

def errors
{}.tap do |e|
e[:endpoint] = 'needs to be updated to v2_endpoint. See upgrade documentation.' if @config.key?('endpoint')
e[:endpoint] = 'needs to be updated to directory. See upgrade documentation.' if @config.key?('endpoint')
NON_BLANK_FIELDS.each do |field|
e[field] = "can't be blank" if public_send(field).nil? || public_send(field) == ''
end
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/test.config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
key_size: 2048
endpoint: 'https://acme.example.com/'
directory: 'https://acme.example.com/'
domains:
- 'example.com'
- 'www.example.com'
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/test_invalid_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ letsencrypt_account_email = "[email protected]"

# The ACME endpoint. Use the staging server until you get everything working.
# Then switch to the production endpoint.
endpoint = "https://acme-staging.api.letsencrypt.org/" # Staging
#endpoint = "https://acme-v01.api.letsencrypt.org/" # Production
directory = "https://acme-staging.api.letsencrypt.org/" # Staging
#directory = "https://acme-v01.api.letsencrypt.org/" # Production

# The URL to the WebFaction API. You should not change this under normal
# circumstances.
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/test_public.config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
key_size: 2048
endpoint: 'https://acme.example.com/'
directory: 'https://acme.example.com/'
domains:
- 'example.com'
- 'www.example.com'
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/test_valid_config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
username = "myusername"
password = "mypassword"
letsencrypt_account_email = "[email protected]"
endpoint = "https://acme-staging.api.letsencrypt.org/" # Staging
directory = "https://acme-staging.api.letsencrypt.org/" # Staging
api_url = "https://wfserverapi.example.com/"
servername = "myservername"

Expand Down
16 changes: 8 additions & 8 deletions spec/lib/letsencrypt_webfaction/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
let(:username) { 'myusername' }
let(:password) { 'mypassword' }
let(:letsencrypt_account_email) { '[email protected]' }
let(:v2_endpoint) { 'https://acme.example.com/' }
let(:directory) { 'https://acme.example.com/' }
let(:additional_config) { '' }
let(:cert_name) { 'mycertname1' }
let(:toml) do
<<-TOML
username = "#{username}"
password = "#{password}"
letsencrypt_account_email = "#{letsencrypt_account_email}"
v2_endpoint = "#{v2_endpoint}"
directory = "#{directory}"
#{additional_config}
[[certificate]]
domains = [
Expand Down Expand Up @@ -41,8 +41,8 @@
end
end

describe '#v2_endpoint' do
subject { options.v2_endpoint }
describe '#directory' do
subject { options.directory }
it { is_expected.to eq 'https://acme.example.com/' }
end

Expand Down Expand Up @@ -106,13 +106,13 @@
context 'with ACMEv1 endpoint' do
let(:additional_config) { 'endpoint = "blah"' }

it { is_expected.to eq(endpoint: 'needs to be updated to v2_endpoint. See upgrade documentation.') }
it { is_expected.to eq(endpoint: 'needs to be updated to directory. See upgrade documentation.') }
end

context 'with invalid v2_endpoint' do
let(:v2_endpoint) { '' }
context 'with invalid directory' do
let(:directory) { '' }

it { is_expected.to eq(v2_endpoint: "can't be blank") }
it { is_expected.to eq(directory: "can't be blank") }
end

context 'with invalid api_url' do
Expand Down
4 changes: 2 additions & 2 deletions templates/letsencrypt_webfaction.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ letsencrypt_account_email = "[email protected]"
# The ACME endpoint. Use the staging server until you get everything working.
# Then switch to the production endpoint. You may want to run with the --force
# command after switching to reissue all certificates.
v2_endpoint = "https://acme-staging-v02.api.letsencrypt.org/directory" # Staging
#v2_endpoint = "https://acme-v02.api.letsencrypt.org/directory" # Production
directory = "https://acme-staging-v02.api.letsencrypt.org/directory" # Staging
#directory = "https://acme-v02.api.letsencrypt.org/directory" # Production

# The URL to the WebFaction API. You should not change this under normal
# circumstances.
Expand Down

0 comments on commit 0b23659

Please sign in to comment.