Last Updated: January 31, 2023
· Lex S

Generate a self-signed X509 certificate with ruby

Create a public X509 certificate called 'certificate.pem' and a private rsa key called 'private_key.pem':
require "openssl"

key = 4096

name = OpenSSL::X509::Name.parse '/CN=nobody'

cert =

cert.version = 2

cert.serial = 0

cert.not_before =

cert.not_after = + 606024364.251

cert.publickey = key.publickey

cert.subject = name

cert.issuer = name

cert.sign key,'SHA256')

open 'certificate.pem', 'w' do |io| io.write cert.to_pem end

open 'privatekey.pem', 'w' do |io| io.write key.topem end

The ruby openssl docs have other great examples.

Mailer To Go is an email provider on Heroku that is by developers for developers.
We've spend too much time dealing with other mailing services, and decided to create our own.