summaryrefslogtreecommitdiff
path: root/lib/e2e/x509.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/e2e/x509.rb')
-rw-r--r--lib/e2e/x509.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/e2e/x509.rb b/lib/e2e/x509.rb
new file mode 100644
index 0000000..898ecc1
--- /dev/null
+++ b/lib/e2e/x509.rb
@@ -0,0 +1,13 @@
+class X509
+ def self.self_signed(key: OpenSSL::PKey::RSA.new(4096))
+ certificate = OpenSSL::X509::Certificate.new
+ certificate.subject = certificate.issuer = OpenSSL::X509::Name.parse("/C=/ST=/L=/O=/OU=/CN=")
+ certificate.not_before = Time.now.to_i
+ certificate.not_after = Time.now.to_i + 600
+ certificate.public_key = key.public_key
+ certificate.serial = 0x01
+ certificate.version = 2
+ certificate.sign(key, OpenSSL::Digest::SHA256.new)
+ certificate
+ end
+end