add_certificate
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
add_certificate(p1, p2, p3 = v3)
public
Adds a certificate to the context. pkey must be a corresponding private key with certificate.
Multiple certificates with different public key type can be added by repeated calls of this method, and OpenSSL will choose the most appropriate certificate during the handshake.
#cert=, #key=, and #extra_chain_cert= are old accessor methods for setting certificate and internally call this method.
Parameters
certificate |
A certificate. An instance of OpenSSL::X509::Certificate. |
pkey |
The private key for certificate. An instance of OpenSSL::PKey::PKey. |
extra_certs |
Optional. An array of OpenSSL::X509::Certificate. When sending a certificate chain, the certificates specified by this are sent following certificate, in the order in the array. |
Example
rsa_cert = OpenSSL::X509::Certificate.new(...) rsa_pkey = OpenSSL::PKey.read(...) ca_intermediate_cert = OpenSSL::X509::Certificate.new(...) ctx.add_certificate(rsa_cert, rsa_pkey, [ca_intermediate_cert]) ecdsa_cert = ... ecdsa_pkey = ... another_ca_cert = ... ctx.add_certificate(ecdsa_cert, ecdsa_pkey, [another_ca_cert])
Note
OpenSSL before the version 1.0.2 could handle only one extra chain across all key types. Calling this method discards the chain set previously.