Bug 196431 - security/ca_root_nss: Fix broken SSL verification for software (and Python) using OpenSSL from ports
Summary: security/ca_root_nss: Fix broken SSL verification for software (and Python) u...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Many People
Assignee: Kubilay Kocak
URL:
Keywords: easy, feature, patch
Depends on:
Blocks: 196357
  Show dependency treegraph
 
Reported: 2015-01-02 06:44 UTC by Kubilay Kocak
Modified: 2017-11-06 09:32 UTC (History)
6 users (show)

See Also:


Attachments
Fix broken SSL verification for software using Ports OpenSSL (2.95 KB, patch)
2015-01-02 06:45 UTC, Kubilay Kocak
no flags Details | Diff
Fix SSL verification for ports OpenSSL v2 (3.43 KB, patch)
2015-01-02 14:01 UTC, Kubilay Kocak
no flags Details | Diff
Port diff to have valid SSL with openssl port (option PORT_ETCSYMLINK) (1.24 KB, patch)
2015-01-28 06:30 UTC, wowi42
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kubilay Kocak freebsd_committer freebsd_triage 2015-01-02 06:44:17 UTC
Since 2.7.9, Python verifies SSL certificates by default. Currently,
even with security/ca_root_nss installed, Python fails certificate
verification.

See: 

https://unix.stackexchange.com/questions/176294/what-should-i-do-about-python-2-7-9-not-looking-for-ssl-certificates-in-the-righ

Python uses OpenSSL's standard SSL_CTX_load_verify_locations to load a
list of CA root certificates. 

Support was added to ca_root_nss for out-of-the-box certificate verification for a number of base utilities in r372629 [1], but this did not include support for software that uses OpenSSL's SSL_CTX_load_verify_locations function.

[1] https://svnweb.freebsd.org/changeset/ports/372629

OpenSSL defaults to the following paths and filenames for the
certificate and CAFile lookup:

Base:
  SSL_CERT_DIR=/etc/ssl/certs
  SSL_CERT_FILE/etc/ssl/cert.pem

Ports:
  SSL_CERT_DIR=/usr/local/openssl/certs
  SSL_CERT_FILE=/usr/local/openssl/cert.pem

This change installs a symlink which points to the root
certificate bundle in the location that OpenSSL from ports looks for them.

This allows any and all software utilising SSL_CTX_load_verify_locations
function to verify SSL certificates by default after installation of
this package.

Additionally, display a pkg-message to the user about the lack of
warranty associated with these certificates. 

Note: This is *NOT* related to solving for SSL certificate verification for OpenSSL in Base, which is covered in bug 189811.


While I'm here:

- Use options helpers and OPTIONS_SUB

portlint: OK
porttest: OK
testport: OK
Comment 1 Bugzilla Automation freebsd_committer 2015-01-02 06:44:17 UTC
Auto-assigned to maintainer gecko@FreeBSD.org
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2015-01-02 06:45:13 UTC
Created attachment 151202 [details]
Fix broken SSL verification for software using Ports OpenSSL
Comment 3 Alfred Perlstein freebsd_committer 2015-01-02 07:23:53 UTC
+1
Comment 4 Jan Beich freebsd_committer 2015-01-02 10:00:19 UTC
>+This enables SSL Certificate Verification by client software without manual
>+intervention.
>+
>+If you prefer to do this manually, remove the following symlinks:
>+
>+  * /etc/ssl/cert.pem
>+  * /usr/local/openssl/cert.pem

This is unreliable:
- the symlinks would be restored upon next update
- pkg-check and pkg-delete would compalin about missing file
- ignores user-maintained certificates (e.g. CA-less config)

@sample keyword can fix them (see bug 196432) with the advice modified to:

  If you prefer to do this manually, replace the following symlinks with
  either an empty file or your site-local certificate bundle:
  
  /etc/ssl/cert.pem
  /usr/local/etc/ssl/cert.pem
  /usr/local/openssl/cert.pem
Comment 5 Kubilay Kocak freebsd_committer freebsd_triage 2015-01-02 10:31:52 UTC
Agreed, thanks for the review & feedback Jan.

I'll v2 the patch
Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2015-01-02 14:01:10 UTC
Created attachment 151211 [details]
Fix SSL verification for ports OpenSSL v2

Patch v2, adds:

- Use @sample for LOCALBASE/etc/ssl and LOCALBASE/openssl symlinks
- Add LICENSE (MPL)
- Add pkg-message to SUB_LIST and variable'ise PREFIX
- Tweak pkg-message
Comment 7 Roller 2015-01-02 15:32:33 UTC
+1
Comment 8 wowi42 2015-01-28 06:30:21 UTC
Created attachment 152293 [details]
Port diff to have valid SSL with openssl port (option PORT_ETCSYMLINK)
Comment 9 Kubilay Kocak freebsd_committer freebsd_triage 2015-01-28 10:28:56 UTC
wowi42, please create a separate issue for your patch introducing a dependency on OpenSSL.
Comment 10 commit-hook freebsd_committer 2015-02-09 09:45:07 UTC
A commit references this bug:

Author: koobs
Date: Mon Feb  9 09:44:29 UTC 2015
New revision: 378720
URL: https://svnweb.freebsd.org/changeset/ports/378720

Log:
  security/ca_root_nss: Fix SSL verification for ports OpenSSL consumers

  Since 2.7.9, Python verifies SSL certificates by default. Currently,
  even with security/ca_root_nss installed, Python fails certificate
  verification.

  Upon investigation, Python uses OpenSSL's standard
  SSL_CTX_load_verify_locations function to load a list of CA root
  certificates.

  Support was added to ca_root_nss for "out of the box" certificate
  verification for a number of base utilities in r372629 [1], but this
  did not include support for software that uses OpenSSL's
  SSL_CTX_load_verify_locations function.

  [1] https://svnweb.freebsd.org/changeset/ports/372629

  OpenSSL defaults (at compile time) to the following paths and filenames
  for certificate and CAFile lookup:

  Base:
    SSL_CERT_DIR=/etc/ssl/certs
    SSL_CERT_FILE/etc/ssl/cert.pem

  Ports:
    SSL_CERT_DIR=/usr/local/openssl/certs
    SSL_CERT_FILE=/usr/local/openssl/cert.pem

  This change installs a symlink which points to the root certificate
  bundle in the location that OpenSSL from ports looks for them.

  This allows any and all software utilising SSL_CTX_load_verify_locations
  function to verify SSL certificates by default after installation of
  this package.

  Additionally, display a pkg-message to the user about the lack of
  warranty associated with these certificates.

  Note: This is *NOT* related to solving for SSL certificate verification
  for OpenSSL in Base, which is covered in bug 189811.

  While I'm here:

  - Add LICENSE
  - Use options helpers and OPTIONS_SUB
  - Fix typo in !!! message !!!

  PR: 196431
  Submitted by:	koobs
  Reviewed by:	jbeich
  Approved by:	maintainer timeout (1 month)

Changes:
  head/security/ca_root_nss/Makefile
  head/security/ca_root_nss/files/pkg-message.in
  head/security/ca_root_nss/pkg-plist
Comment 11 Kubilay Kocak freebsd_committer freebsd_triage 2015-02-09 09:49:57 UTC
Committed, with minor changes.