Skip to content

Instantly share code, notes, and snippets.

@mcr
Last active March 16, 2019 22:27
Show Gist options
  • Select an option

  • Save mcr/96000bdfd516306dbedfadf16953733a to your computer and use it in GitHub Desktop.

Select an option

Save mcr/96000bdfd516306dbedfadf16953733a to your computer and use it in GitHub Desktop.

Revisions

  1. mcr revised this gist Mar 16, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@
    m.type = :txt
    m.zone = "dasblinkenled.org"
    m.hostname = target
    m.data = challenge.token
    m.data = challenge.record_content
    }
    sleep(30)
    puts "NIC"
  2. mcr created this gist Mar 16, 2019.
    49 changes: 49 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    # something wrong with authenticating the SSL key for staging server.
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

    # AcmeKeys is a local class that collects stuff including the key pair for authenticating and options,
    # and which server to talk to, and DNS update options for my dasblinkenled.org zone.
    puts "Server at: #{AcmeKeys.acme.server}"
    client = Acme::Client.new(private_key: AcmeKeys.acme.acmeprivkey,
    directory: AcmeKeys.acme.server)
    account = client.new_account(contact: 'mailto:minerva@sandelman.ca',
    terms_of_service_agreed: true)

    zone = "ne34db3.r.dasblinkenled.org"
    order = client.new_order(identifiers: [zone])
    authorization = order.authorizations.first
    challenge = authorization.dns
    expect(challenge.record_name).to eq("_acme-challenge") # good check for sanity, but could change

    dns = DnsUpdate::load AcmeKeys.acme.update_options
    target = challenge.record_name + "." + zone
    puts "Removing old challenge from #{target}"
    dns.remove { |m|
    m.type = :txt
    m.zone = "dasblinkenled.org"
    m.hostname = target
    }
    sleep(1)
    puts "Adding #{challenge.token} challenge to #{target}"
    dns.update { |m|
    m.type = :txt
    m.zone = "dasblinkenled.org"
    m.hostname = target
    m.data = challenge.token
    }
    sleep(30)
    puts "NIC"
    system("dig +short @nic.sandelman.ca #{target} txt")
    puts "SNS"
    system("dig +short @sns.cooperix.net #{target} txt")
    sleep(30)
    challenge.request_validation

    while challenge.status == 'pending'
    puts "Challenge waiting"
    sleep(2)
    challenge.reload
    end
    puts "Status: #{challenge.status}"
    byebug
    expect(challenge.status).to eq('valid')