Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssl: add SSLContext#add_certificate #167

Merged
merged 4 commits into from
Nov 22, 2017

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Oct 30, 2017

Add a new method to add a certificate, a corresponding private key and
extra CA certificates at once.

This has two advantages over the existing {cert,key,extra_cert_chain}
attributes:

  1. We can notice the problem with the certificate and/or the private
    key. Since the existing attributes are just instance variables,
    they aren't set to the SSL_CTX until #setup which usually happens
    on the first connection.

  2. For the same reason, existing attributes allowed only one
    certificate for a context, even though OpenSSL itself is capable of
    handling multiple certificates and selecting the most appropriate
    one according to the cipher suite selected.

The existing attributes are now 'soft' deprecated and their RDoc
comments are updated to recommend #add_certificate.

EnvUtil.verbose_warning used by assert_warning is also ported.
PKey::EC#public_key works differently from other PKey types, making
TestUtils.issue_cert unusable for creating ECDSA certificates.
Actually, the #public_key does not have any effect on any other PKey
types. So just remove it.
Add a new method to add a certificate, a corresponding private key, and
extra CA certificates at once.

This has two advantages over the existing {cert,key,extra_cert_chain}
attributes:

  1. We can notice the problem with the certificate and/or the private
     key. Since the existing attributes are simple instance variables,
     they aren't set to the SSL_CTX until #setup which usually happens
     on the first connection.

  2. For the same reason, existing attributes allowed only one
     certificate for a context, even though OpenSSL itself is capable of
     handling multiple certificates and selecting the most appropriate
     one according to the cipher suite selected.

The documentation for the existing attributes are updated to recommend
using #add_certificate.
Fix test_security_level using SSLContext#add_certificate. It immediately
sets the certificate to the SSL_CTX, so it is affected by the security
level setting.
@rhenium rhenium merged commit 0b6ac1a into ruby:master Nov 22, 2017
rhenium added a commit that referenced this pull request Nov 22, 2017
Merge GitHub Pull Request #167.

* ky/ssl-add-certificate:
  test/test_ssl: fix test_security_level
  ssl: add SSLContext#add_certificate
  test/utils: remove a pointless .public_key call in issue_cert
  test/envutil: port assert_warning from Ruby trunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant