Project

easyrsa

0.02
No commit activity in last 3 years
No release in over 3 years
Easily generate OpenVPN certificates without needing the easyrsa packaged scripts
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

ruby-easyrsa

Build Status

Dependency Status

Gem Version

Generate OpenVPN certificate and keys with Ruby using this gem.

Installation

Via command line use gem:

gem install easyrsa

or add it to your projects Gemfile:

gem 'easyrsa'

and simply require it in your code:

require 'easyrsa'

Usage

First, set your issuer configuration like so:

EasyRSA.configure do |issuer|
  issuer.email = 'support@company.com'
  issuer.name = 'MrKickass'
  issuer.server = 'vpnserver.company.com'
  issuer.country = 'US'
  issuer.state = 'NY'
  issuer.city = 'New York'
  issuer.company = 'My Company'
  issuer.orgunit = 'IT'
end

Generate a Client Certificate

Use the EasyRSA::Certificate class to generate the certificate:

cn = 'Users Common Name'
email = 'users-common-name@company.com'
easyrsa = EasyRSA::Certificate.new(@ca_cert, @ca_key, cn, email)
g = easyrsa.generate
 #=> [:key => '...RSA KEY...', :crt => '...CERTIFICATE...']

Note ca_cert and ca_key should point to the same certificate and keys that are included in your OpenVPN configuration file.

Generate the CA files

The following can be used to create a Certificate Authority:

ca = EasyRSA::CA.new('CN=openvpn/DC=example/DC=com')
g = ca.generate
 #=> [:key => '...RSA KEY...', :crt => '...CERTIFICATE...']

Revoking Certificates

The following can be used to create revoke a certificate:

easyrsa = EasyRSA::Certificate.new(@ca_cert, @ca_key, 'mike', 'mike@ruby-easyrsa.gem')
g = easyrsa.generate

r = EasyRSA::Revoke.new g[:crt]
crl = r.revoke! @ca_key
 #=> -----BEGIN X509 CRL-----
 #   MIIBjTCB9wIBATANBgkqhkiG9w0BAQsFADCBpDELMAkGA1UEBhMCVVMxETAPBgNV

Generating Deffie-Hellman

The following can be used to generate Deffie-Hellman:

easyrsa = EasyRSA::DH.new
g = easyrsa.generate
puts g
 #=> -----BEGIN DH PARAMETERS-----

Credits

Many thanks to: