本文簡要介紹ruby語言中 OpenSSL::SSL::SSLContext.add_certificate
的用法。
用法
add_certificate(certificate, pkey [, extra_certs]) → self
將證書添加到上下文。 pkey
必須是與 certificate
對應的私鑰。
多次調用該方法可以添加多個不同公鑰類型的證書, OpenSSL
會在握手過程中選擇最合適的證書。
cert=
、 key=
和 extra_chain_cert=
是用於設置證書的舊訪問器方法,並在內部調用此方法。
參數
certificate
-
證書。
OpenSSL::X509::Certificate
的一個實例。 pkey
-
certificate
的私鑰。OpenSSL::PKey::PKey
的一個實例。 extra_certs
-
可選的。
OpenSSL::X509::Certificate
的數組。發送證書鏈時,此指定的證書按照數組中的順序在certificate
之後發送。
示例
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])
相關用法
- Ruby SSLContext.alpn_select_cb用法及代碼示例
- Ruby SSLContext.alpn_protocols用法及代碼示例
- Ruby SSLContext.renegotiation_cb用法及代碼示例
- Ruby SSLContext.min_version =用法及代碼示例
- Ruby SSLContext.ecdh_curves =用法及代碼示例
- Ruby SSLContext.tmp_dh =用法及代碼示例
- Ruby SSLContext.npn_protocols用法及代碼示例
- Ruby SSLContext.npn_select_cb用法及代碼示例
- Ruby SSLConfig.new用法及代碼示例
- Ruby SSLSocket.open用法及代碼示例
- Ruby SSLSocket.accept_nonblock用法及代碼示例
- Ruby SSLSocket.connect_nonblock用法及代碼示例
- Ruby Symbol capitalize用法及代碼示例
- Ruby SizedQueue clear()用法及代碼示例
- Ruby Spotter.spot_op_asgn2_for_name用法及代碼示例
- Ruby StringScanner skip_until用法及代碼示例
- Ruby StringScanner search_full用法及代碼示例
- Ruby String.match?用法及代碼示例
- Ruby StringScanner.beginning_of_line?用法及代碼示例
- Ruby Stat.stat <=>用法及代碼示例
- Ruby Symbol.to_proc用法及代碼示例
- Ruby Symbol.end_with?用法及代碼示例
- Ruby StringScanner restsize用法及代碼示例
- Ruby Spotter.spot_opcall_for_name用法及代碼示例
- Ruby Set flatten()用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 SSLContext.add_certificate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。