From: Andreas Enge <andreas@enge.fr>
To: guix-devel@gnu.org
Subject: Openssl and certificate directory
Date: Sat, 7 Feb 2015 16:17:48 +0100 [thread overview]
Message-ID: <20150207151748.GA6943@debian> (raw)
[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]
Hello,
the attached patch does the same thing as we just pushed for gnutls:
It sets the global certificate store to files and directories inside
/etc/ssl. It should be applied after the update to 1.0.2, which I am
trying to have built by hydra on the wip-openssl branch (except that hydra
refuses to evaluate this for the last few hours, did I make a mistake?).
I tried youtube-dl with it, and it works now out of the box with the
certificates that debian puts into /etc/ssl/certs/.
Unless there are complaints, I would like to push it to master once hydra
has built enough packages with it.
In the long run, we might wish to apply a mixture of the two attached
patches from nix: They take the certificate location from the environment
variable OPENSSL_X509_CERT_FILE if it is defined, and only if the binary
is not setuid. The patch concerns only the cert file, a file with lots
of certificates concatenated; I would rather be in favour of patching the
next function, X509_get_default_cert_dir_env, which defines a directory
with lots of separate certificates. These could come from separate
certificate packages. We could then also add a search path to set the
environment variable.
Andreas
[-- Attachment #2: 0001-gnu-openssl-Use-etc-ssl-as-the-base-directory-for-ce.patch --]
[-- Type: text/plain, Size: 1298 bytes --]
From 7e54dd89d698d1209f9cc2cfde95f9f6fd0ecbaf Mon Sep 17 00:00:00 2001
From: Andreas Enge <andreas@enge.fr>
Date: Sat, 7 Feb 2015 13:14:27 +0100
Subject: [PATCH] gnu: openssl: Use /etc/ssl as the base directory for
certificates.
* gnu/packages/openssl.scm (openssl)[source]: Add a snippet to use
/etc/ssl/certs/ as the directory and /etc/ssl/cert.pem as the
file where certificates are searched.
---
gnu/packages/openssl.scm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/openssl.scm b/gnu/packages/openssl.scm
index 34e1351..b6dfe6d 100644
--- a/gnu/packages/openssl.scm
+++ b/gnu/packages/openssl.scm
@@ -36,7 +36,13 @@
".tar.gz"))
(sha256
(base32
- "1s988w1h1yxh7lhrhh164hv6vil94lkwzh6g2rfm03dypbrvlj4c"))))
+ "1s988w1h1yxh7lhrhh164hv6vil94lkwzh6g2rfm03dypbrvlj4c"))
+ (modules '((guix build utils))) ; for substitute*
+ (snippet
+ '(begin
+ ;; Use /etc/ssl as the base directory for certificates.
+ (substitute* "crypto/cryptlib.h"
+ (("OPENSSLDIR") "\"/etc/ssl\""))))))
(build-system gnu-build-system)
(native-inputs `(("perl" ,perl)))
(arguments
--
2.2.1
[-- Attachment #3: cert-file.patch --]
[-- Type: text/plain, Size: 1084 bytes --]
diff -ru -x '*~' openssl-1.0.0e-orig/crypto/x509/x509_def.c openssl-1.0.0e/crypto/x509/x509_def.c
--- openssl-1.0.0e-orig/crypto/x509/x509_def.c 1999-09-11 19:54:11.000000000 +0200
+++ openssl-1.0.0e/crypto/x509/x509_def.c 2011-09-12 18:30:59.386501609 +0200
@@ -57,6 +57,10 @@
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
#include "cryptlib.h"
#include <openssl/crypto.h>
#include <openssl/x509.h>
@@ -71,7 +75,25 @@
{ return(X509_CERT_DIR); }
const char *X509_get_default_cert_file(void)
- { return(X509_CERT_FILE); }
+ {
+ static char buf[PATH_MAX] = X509_CERT_FILE;
+ static int init = 0;
+ if (!init) {
+ init = 1;
+ char * s = getenv("OPENSSL_X509_CERT_FILE");
+ if (s) {
+#ifndef OPENSSL_SYS_WINDOWS
+ if (getuid() == geteuid()) {
+#endif
+ strncpy(buf, s, sizeof(buf));
+ buf[sizeof(buf) - 1] = 0;
+#ifndef OPENSSL_SYS_WINDOWS
+ }
+#endif
+ }
+ }
+ return buf;
+ }
const char *X509_get_default_cert_dir_env(void)
{ return(X509_CERT_DIR_EVP); }
[-- Attachment #4: cert-file-path-max.patch --]
[-- Type: text/plain, Size: 1038 bytes --]
This patch, to be applied after `cert-file.patch', fixes compilation
on GNU/Hurd where `PATH_MAX' is not defined.
diff -ubB --show-c-function openssl-1.0.0e/crypto/x509/x509_def.c.orig openssl-1.0.0e/crypto/x509/x509_def.c
--- openssl-1.0.0e/crypto/x509/x509_def.c.orig 2012-01-06 00:08:48.000000000 +0100
+++ openssl-1.0.0e/crypto/x509/x509_def.c 2012-01-06 00:11:29.000000000 +0100
@@ -58,6 +58,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <sys/types.h>
@@ -76,14 +77,16 @@ const char *X509_get_default_cert_dir(vo
const char *X509_get_default_cert_file(void)
{
- static char buf[PATH_MAX] = X509_CERT_FILE;
+ static char *buf;
static int init = 0;
if (!init) {
init = 1;
char * s = getenv("OPENSSL_X509_CERT_FILE");
if (s && getuid() == geteuid()) {
- strncpy(buf, s, sizeof(buf));
- buf[sizeof(buf) - 1] = 0;
+ buf = strdup(s);
+ }
+ if (!s) {
+ buf = strdup(X509_CERT_FILE);
}
}
return buf;
next reply other threads:[~2015-02-07 15:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-07 15:17 Andreas Enge [this message]
2015-02-08 1:57 ` Openssl and certificate directory Mark H Weaver
2015-02-08 9:49 ` Andreas Enge
2015-02-08 14:22 ` Ludovic Courtès
2015-02-08 15:49 ` Mark H Weaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150207151748.GA6943@debian \
--to=andreas@enge.fr \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).