Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > opensslライブラリ > OpenSSL::X509::Requestクラス

class OpenSSL::X509::Request

クラスの継承リスト: OpenSSL::X509::Request < Object < Kernel

要約

X.509 の証明書署名要求(Certificate Signing Request, CSR)を表わす クラスです。

X.509 CSR については [RFC2986] などを参照してください。

CSR を生成する例。

require 'openssl'
# ファイルから秘密鍵を読み込む
rsa = OpenSSL::PKey::RSA.new(File.read("privkey.pem"))
# 新しい CSR オブジェクトを生成
csr = OpenSSL::X509::Request.new
# DN を生成
name = OpenSSL::X509::Name.new
name.add_entry('C', 'JP')
name.add_entry('ST', 'Osaka')
name.add_entry('CN', 'Example Name')
csr.subject = name
# バージョンを 0 (v1.7) に
csr.version = 0
# 公開鍵を CSR に設定
csr.public_key = rsa.public_key
# attribute を設定
factory = OpenSSL::X509::ExtensionFactory.new
exts = [ factory.create_ext("subjectAltName", "DNS:foo.example.com") ]
asn1exts = OpenSSL::ASN1::Set([OpenSSL::ASN1::Sequence(exts)])
csr.add_attribute(OpenSSL::X509::Attribute.new("extReq", asn1exts))
# 署名
csr.sign(rsa, "sha1")
# PEM 形式で標準出力に出力
puts csr.to_pem

特異メソッド

定義 説明
new -> OpenSSL::X509::Request
new(obj) -> OpenSSL::X509::Request

新しい OpenSSL::X509::Request オブジェクトを生成します。

インスタンスメソッド

定義 説明
add_attribute(attr) -> OpenSSL::X509::Attribute

新たな attribute を CSR に追加します。

attributes -> [OpenSSL::X509::Attribute]

CSR が保持している attribute を OpenSSL::X509::Attribute の配列で返します。

attributes=(attrs)

CSR の attribute をクリアして新しい attribute を設定します。

public_key -> OpenSSL::PKey::PKey

申請者の公開鍵を返します。

public_key=(pkey)

申請者の公開鍵を設定します。

sign(key, digest) -> self

証明書署名要求に秘密鍵で署名をします。

signature_algorithm -> String

証明書署名要求の署名に使われているアルゴリズム名を文字列で返します。

subject -> OpenSSL::X509::Name

証明書署名要求の申請者名を返します。

subject=(subject)

証明書署名要求の申請者名を設定します。

to_der -> String

DER 形式の文字列に変換して返します。

to_pem -> String
to_s -> String

PEM 形式の文字列に変換して返します。

to_text -> String

人間が読める形式の文字列に変換して返します。

verify(key) -> bool

署名を検証します。

version -> Integer

バージョンを返します。

version=(version)

バージョンを設定します。

継承したメソッド

== === =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_str to_yaml to_yaml_properties to_yaml_style untaint