diff options
author | GOTOU Yuuzou <gotoyuzo@notwork.org> | 2003-06-13 17:43:51 +0000 |
---|---|---|
committer | GOTOU Yuuzou <gotoyuzo@notwork.org> | 2003-06-13 17:43:51 +0000 |
commit | 512fb18eb59c00938dd4e0a1173b2f211a2efe8e (patch) | |
tree | a03fce02a05230965fec6ed735ddb52cc7d1ea12 | |
parent | b27eadc1cf13d82ee9c153f4c847c8f19dad041c (diff) | |
download | ruby-openssl-history-512fb18eb59c00938dd4e0a1173b2f211a2efe8e.tar.gz |
ossl_ssl.c
-rw-r--r-- | examples/0cert.pem | 38 | ||||
-rw-r--r-- | examples/0key.pem | 52 | ||||
-rwxr-xr-x | examples/gen_cert.rb | 15 | ||||
-rw-r--r-- | ossl_pkcs7.c | 13 | ||||
-rw-r--r-- | ossl_ssl.c | 2 |
5 files changed, 63 insertions, 57 deletions
diff --git a/examples/0cert.pem b/examples/0cert.pem index 352ac93..305659d 100644 --- a/examples/0cert.pem +++ b/examples/0cert.pem @@ -1,22 +1,22 @@ -----BEGIN CERTIFICATE----- -MIIDjzCCAnegAwIBAgIBADANBgkqhkiG9w0BAQUFADAtMQ8wDQYDVQQDEwZSdWJ5 -Q0ExCzAJBgNVBAYTAkNaMQ0wCwYDVQQKEwRSdWJ5MB4XDTAyMDYxMTAwMjIyMVoX -DTA0MDYxMDAwMjIyMVowLTEPMA0GA1UEAxMGUnVieUNBMQswCQYDVQQGEwJDWjEN -MAsGA1UEChMEUnVieTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKci -NrSlcXfcNCFqeQK6qwFFCXLif35Zq52tJu0zTG5Jh3aSfLjDxgCsK+/b4AEjVdGy -a/c/Xn+P8zeiXaw7xUBRffk0SCkM15J0+lJtB+LwImLD7mFvwfwMd0lEgm+Aa8ua -BfChQ82bp1oJimqVx2n1zPuf2l6TZ4gvtgFnARViBMUUNCvMW/2CWjzEAMHmfC9A -c4DbySNbWiRswS6QmaIurC0oWsVinXkBycPURuyN3nBZ5Qd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-ehgdzT8T0O7TrwA3MKN+HhLL+utgQw7x58OdJamnNPi/8m0vOkHEr13Cb+Rco3yl -TEJgEJehXic1/SxxNq/2H2VC7/5EWv1McukrCNIU6pq/T/mbF79wwc0WiPf2zB7S -Okwnv2Dfg0vaOdWEGwS1qKyWK8Pz49pzLGtmOlrYxN2pDeWeCbOejCjLHrm884pR -xAvNvv2m3Mil9dMVTtnw41nZj/olTh23cgACZqNYgCZ2YHO8WY3ysYORsBb4viRK -gZtma+CWP8FEHWA0QaSzljMM/6ME7sYiHALUP1+36UIhaEUfkJmsUqtmyNeHGnZf -BW7A +BBYEFIs6lVzOhhiM8EGU1mp7BqpWRZD/MFUGA1UdIwROMEyAFIs6lVzOhhiM8EGU +1mp7BqpWRZD/oTGkLzAtMQswCQYDVQQGEwJDWjENMAsGA1UEChMEUnVieTEPMA0G +A1UEAxMGUnVieUNBggEAMA0GCSqGSIb3DQEBBQUAA4IBAQANXkq38cgQnirqeTmZ +eNqWELevBL/62aMCNmoVtGTX1Uk76opGF2QyTxjk8h3pzpzYLPdIOTK/wwxCB9iW +v+9LAey/mjvJNZMv+GcS5qFuRHx1eprtLYxePpeosx0zqbsiK774uiySKxCjRCqr +TncxcnaM22lQ8N7ubgdoV1CT2dO4lMU7UZf0BSX04Av+wa8NQT+ckXX6mxSHRBxJ +7zIxqw3FNay5QArH2UzfI6pSSmxgPMtdLqVB6iSO2g6AU130spUmUP0VDBRhUZJt +Cj+KqdK6iUHICzRj+/3H8MlqiLmHTyJyvihoUXqmEC/6mS1lsKACDccq2VApPA4x +LfcZ -----END CERTIFICATE----- diff --git a/examples/0key.pem b/examples/0key.pem index a6ef891..f41c001 100644 --- a/examples/0key.pem +++ b/examples/0key.pem @@ -1,30 +1,30 @@ -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,87454D4F89D679DC +DEK-Info: DES-EDE3-CBC,3C95B3325D7EAE8A -HWZxOMvENKCdQx1P6UiEfH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--git a/examples/gen_cert.rb b/examples/gen_cert.rb index 1ec9e34..d6f53a0 100755 --- a/examples/gen_cert.rb +++ b/examples/gen_cert.rb @@ -5,18 +5,25 @@ include OpenSSL include X509 include PKey -p ca = Certificate.new(File.open("./0cert.pem").read) -p ca_key = RSA.new(File.open("./0key.pem").read) +usage = "#{$0} cn ca_cert_file ca_key_file serial" + +cn = ARGV.shift or raise usage +ca_cert_file = ARGV.shift or raise usage +ca_key_file = ARGV.shift or raise usage +serial = ARGV.shift or raise usage + +p ca = Certificate.new(File.open(ca_cert_file).read) +p ca_key = RSA.new(File.open(ca_key_file).read) p key = RSA.new(1024) p new = Certificate.new -name = [['C', 'CZ'],['O','Ruby'],['CN','RA Officer']] +name = [['C', 'CZ'],['O','Ruby'],['CN',cn]] p new.subject = Name.new(name) p new.issuer = ca.subject p new.not_before = Time.now p new.not_after = Time.now + (365*24*60*60) p new.public_key = key -p new.serial = 1 +p new.serial = serial.to_i p new.version = 2 ef = ExtensionFactory.new ef.subject_certificate = new diff --git a/ossl_pkcs7.c b/ossl_pkcs7.c index 27d5d0a..1e644a7 100644 --- a/ossl_pkcs7.c +++ b/ossl_pkcs7.c @@ -213,19 +213,18 @@ ossl_pkcs7_set_cipher(VALUE self, VALUE cipher) } static VALUE -ossl_pkcs7_add_signer(VALUE self, VALUE signer, VALUE key) +ossl_pkcs7_add_signer(VALUE self, VALUE signer) { PKCS7 *pkcs7; PKCS7_SIGNER_INFO *p7si; - EVP_PKEY *pkey; GetPKCS7(self, pkcs7); OSSL_Check_Kind(signer, cPKCS7SignerInfo); - pkey = DupPrivPKeyPtr(key); - /* DUP needed to make PKCS7_add_signer GCsafe */ + p7si = ossl_pkcs7si_get_PKCS7_SIGNER_INFO(signer); - p7si->pkey = pkey; - + + /* NO DUP needed: PKCS7_SIGNER_INFO_set increments the + reference-count of the underlying pkey. */ if (!PKCS7_add_signer(pkcs7, p7si)) { PKCS7_SIGNER_INFO_free(p7si); ossl_raise(ePKCS7Error, "Could not add signer."); @@ -563,7 +562,7 @@ Init_ossl_pkcs7() rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, 1); rb_define_copy_func(cPKCS7, ossl_pkcs7_copy); - rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 2); + rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 1); rb_define_method(cPKCS7, "signers", ossl_pkcs7_get_signer, 0); rb_define_method(cPKCS7, "cipher=", ossl_pkcs7_set_cipher, 1); rb_define_method(cPKCS7, "add_recipient", ossl_pkcs7_add_recipient, 1); @@ -216,7 +216,7 @@ ossl_sslctx_setup(VALUE self) val = ossl_sslctx_get_passwd_cb(self); if(!NIL_P(val)){ - SSL_CTX_set_default_passwd_cb_userbata(ctx, val); + SSL_CTX_set_default_passwd_cb_userdata(ctx, val); SSL_CTX_set_default_passwd_cb(ctx, ossl_ssl_passwd_cb); } |