1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

chore: add script for generating smtp TLS certificates

هذا الالتزام موجود في:
Adam Cooke
2024-02-15 09:36:09 +00:00
ملتزم من قبل Adam Cooke
الأصل 8d21adcbd4
التزام 6eb16c3fab

عرض الملف

@@ -0,0 +1,23 @@
# frozen_string_literal: true
require File.expand_path("../lib/postal/config", __dir__)
require "openssl"
unless File.exist?(Postal.smtp_private_key_path)
key = OpenSSL::PKey::RSA.new(2048).to_s
File.write(Postal.smtp_private_key_path, key)
puts "Created new private key for encrypting SMTP connections"
end
unless File.exist?(Postal.smtp_certificate_path)
cert = OpenSSL::X509::Certificate.new
cert.subject = cert.issuer = OpenSSL::X509::Name.parse("/C=GB/O=Test/OU=Test/CN=Test")
cert.not_before = Time.now
cert.not_after = Time.now + (365 * 24 * 60 * 60)
cert.public_key = Postal.smtp_private_key.public_key
cert.serial = 0x0
cert.version = 2
cert.sign Postal.smtp_private_key, OpenSSL::Digest.new("SHA256")
File.write(Postal.smtp_certificate_path, cert.to_pem)
puts "Created new self signed certificate for encrypting SMTP connections"
end