Mechanize::Form::Keygen

This class represents a keygen (public / private key generator) found in a Form. The field will automatically generate a key pair and compute its own value to match the challenge. Call key to access the public/private key pair.

Attributes

challenge[R]

The challenge for this .

key[R]

The key associated with this tag.

Public Class Methods

new(node, value = nil) click to toggle source
    # File lib/mechanize/form/keygen.rb, line 14
14:   def initialize(node, value = nil)
15:     super
16:     @challenge = node['challenge']
17: 
18:     @spki = OpenSSL::Netscape::SPKI.new
19:     @spki.challenge = @challenge
20: 
21:     @key = nil
22:     generate_key if value.nil? || value.empty?
23:   end

Public Instance Methods

generate_key(key_size = 2048) click to toggle source

Generates a key pair and sets the field’s value.

    # File lib/mechanize/form/keygen.rb, line 26
26:   def generate_key(key_size = 2048)
27:     # Spec at http://dev.w3.org/html5/spec/Overview.html#the-keygen-element
28:     @key = OpenSSL::PKey::RSA.new key_size
29:     @spki.public_key = @key.public_key
30:     @spki.sign @key, OpenSSL::Digest::MD5.new
31:     self.value = @spki.to_pem
32:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.