Sha256: b1023ce1c62d96ed29722f8ac951f022cb04518a54a65cf38ddc1033f8bca690

Contents?: true

Size: 1013 Bytes

Versions: 30

Compression:

Stored size: 1013 Bytes

Contents

#!/usr/bin/env ruby

require 'uri'
require 'securerandom'
require 'logger'
require 'sequel'

uri_string = ARGV[0]
database = ARGV[1]
raise "Usage: #{__FILE__} URI SQLITE_DATABASE_PATH" unless uri_string && database

# Modify this hash with the configuration for your database
DATABASE_CREDENTIALS = {logger: Logger.new($stdout), adapter: "sqlite", database: database, :encoding => 'utf8'}

uri = URI(uri_string)
connection = Sequel.connect(DATABASE_CREDENTIALS)

certificate_command = "openssl s_client -showcerts -servername #{uri.host} -connect #{uri.host}:#{uri.port} </dev/null 2>/dev/null | openssl x509 -outform PEM"
certificate_content = `#{certificate_command}`

puts "Downloaded certificate from #{uri.host}: #{certificate_content}"

certificate_hash = {
  uuid: SecureRandom.urlsafe_base64,
  description: "Self signed certificate for #{uri.host}",
  content: certificate_content,
  created_at: DateTime.now,
  updated_at: DateTime.now
}

connection[:certificates].insert(certificate_hash)

puts "Done"

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
pact_broker-2.30.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.29.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.27.6 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.27.5 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.27.4 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.27.3 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.27.2 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.27.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.26.1 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.26.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.25.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.24.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.23.4 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.23.3 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.23.2 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.23.1 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.23.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.22.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.21.0 script/insert-self-signed-certificate-from-url.rb
pact_broker-2.20.0 script/insert-self-signed-certificate-from-url.rb