lib/global_session/keystore.rb in global_session-3.2.4 vs lib/global_session/keystore.rb in global_session-3.2.5
- old
+ new
@@ -60,10 +60,21 @@
def initialize(configuration)
@configuration = configuration
load
end
+ # Factory method to generate a new keypair for use with GlobalSession.
+ #
+ # @raise [ArgumentError] if cryptosystem is unknown to OpenSSL
+ # @return [OpenSSL::PKey::PKey] a public/private keypair
+ def self.create_keypair(cryptosystem=:RSA, keysize=1024)
+ factory = OpenSSL::PKey.const_get(cryptosystem)
+ factory.generate( 1024 )
+ rescue NameError => e
+ raise ArgumentError, e.message
+ end
+
private
# Load all public and/or private keys from location(s) specified in the configuration's
# "keystore/public" and "keystore/private" directives.
#
@@ -134,6 +145,6 @@
else
raise Errno::ENOENT.new("Path is not a file: " + path)
end
end
end
-end
\ No newline at end of file
+end