Sha256: 306dc551985155a8c2dacea6ac101ab7abfc8d0887c4a7ea3ed331a686606e07
Contents?: true
Size: 1.19 KB
Versions: 12
Compression:
Stored size: 1.19 KB
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 # For example, a postgres connection would look like: # DATABASE_CREDENTIALS = {logger: Logger.new($stdout), adapter: "postgres", host: "HOST", username: "USERNAME", password: "PASSWORD", :encoding => 'utf8'} 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
12 entries across 12 versions & 1 rubygems