Skip to content

Commit 35a7a7a

Browse files
committed
SOFTWARE-5745: re-add el9 SHA1 fixes
1 parent 76ba2f8 commit 35a7a7a

2 files changed

Lines changed: 77 additions & 5 deletions

File tree

add-trusted-sha1-certs.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Helper script to facilitate generating two packages out of the certificate directory, one with
2+
# the certs as-is ($ORIG_SUFFIX) and one with all sha1 certs replaced by trusted certs
3+
4+
# For each sha1-signed cert, create a duplicate trusted version to comply with EL9 default security policies
5+
# Give the original and trusted versions separate file suffixes, and also generate a separate set of
6+
# sha256sums for
7+
8+
# Directory to modify certs in
9+
CERT_DIR=$1
10+
# File suffix to apply to unmodified sha1 certs
11+
TRUST_SUFFIX=$2
12+
# File suffix to apply to modified sha1 certs
13+
ORIG_SUFFIX=$3
14+
15+
# util function to find every sha1-signed cert
16+
find_sha1_certs() {
17+
for f in $(find $1 -name "*.pem"); do
18+
if openssl x509 -noout -text < $f | grep "Signature Algorithm.*sha1" > /dev/null; then
19+
echo $f
20+
fi
21+
done
22+
}
23+
24+
pushd $CERT_DIR
25+
26+
# Rename the original sha256sum file that will be included with the package containing unmodified certs
27+
mv cacerts_sha256sum.txt cacerts_sha256sum.txt.$ORIG_SUFFIX
28+
29+
# Then, find every sha1 certificate that will need to be changed to a trusted certificate
30+
TO_CHANGE=$(find_sha1_certs .)
31+
32+
# change the certificate header/footer of SHA1-signed certificates to mark them as trusted
33+
echo $TO_CHANGE | xargs sed -r -i.orig -e 's/(BEGIN|END) CERTIFICATE/\1 TRUSTED CERTIFICATE/'
34+
# then append the originals to the certificate files so the files will contain both
35+
for orig in *.orig; do
36+
new=${orig%.orig}
37+
(echo; cat "$orig" ) >> "$new"
38+
# Rename the original versions of each sha1 cert so they'll be included in the unmodified package
39+
mv "$orig" "$new.$ORIG_SUFFIX"
40+
done
41+
42+
# Create a new sha256sum file for the package containing updated certs
43+
sha256sum *.0 *.pem > cacerts_sha256sum.txt.$TRUST_SUFFIX
44+
45+
# Rename the modified versions of each sha1 cert so they'll be included in the trusted package
46+
for new in $TO_CHANGE; do
47+
mv "$new" "$new.$TRUST_SUFFIX"
48+
done
49+
50+
popd

rpm/osg-ca-certs.spec

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Name: osg-ca-certs
66
Version: %{osg_version}
7-
Release: 1%{?dist}
7+
Release: 2%{?dist}
88
Summary: OSG Packaging of the IGTF CA Certs and OSG-specific CAs, in the OpenSSL 1.0.* format.
99

1010
License: Unknown
@@ -13,6 +13,7 @@ URL: http://repo.opensciencegrid.org/cadist/
1313
Source0: https://github.com/opensciencegrid/osg-certificates/archive/v%{vtag}/osg-certificates-%{vtag}.tar.gz
1414
Source1: https://dist.eugridpma.info/distribution/igtf/current/igtf-policy-installation-bundle-%{igtf_version}.tar.gz
1515
Source2: https://github.com/opensciencegrid/letsencrypt-certificates/archive/v0.3.2/letsencrypt-certificates.tar.gz
16+
Source3: trusted_sha1_certs.sh
1617
# can obtain latest letsencrypt-certificates.tar.gz with a github.source line:
1718
# type=github repo=cilogon/letsencrypt-certificates tarball=letsencrypt-certificates.tar.gz tag=master hash=...
1819

@@ -31,10 +32,20 @@ Conflicts: osg-ca-scripts
3132
Obsoletes: vdt-ca-certs
3233
Obsoletes: osg-ca-certs-experimental
3334
Obsoletes: osg-ca-certs-compat <= 1:1.37
35+
RemovePathPostfixes: .trusted-cert
3436

3537
%description
3638
For details about the current certificate release, see https://repo.opensciencegrid.org/cadist/ and change log at https://repo.opensciencegrid.org/cadist/CHANGES.
3739

40+
%package java
41+
Summary: Java-compatible SHA1 certs for %{name}
42+
BuildArch: noarch
43+
Conflicts: osg-ca-scripts
44+
RemovePathPostfixes: .java-cert
45+
46+
%description java
47+
For details about the current certificate release, see https://repo.opensciencegrid.org/cadist/ and change log at https://repo.opensciencegrid.org/cadist/CHANGES.
48+
3849
%prep
3950
%setup -n osg-certificates-%{vtag}
4051
%setup -D -n osg-certificates-%{vtag} -a 1
@@ -48,22 +59,34 @@ export CADIST=$PWD/certificates
4859
export PKG_NAME=%{name}
4960

5061
./build-certificates-dir.sh
62+
./add-trusted-sha1-certs.sh certificates trusted-cert java-cert
5163

5264
%install
5365
mkdir -p $RPM_BUILD_ROOT/etc/grid-security/certificates
5466
mv certificates/* $RPM_BUILD_ROOT/etc/grid-security/certificates/
5567

5668
%check
57-
cd $RPM_BUILD_ROOT/etc/grid-security/certificates
58-
sha256sum -c cacerts_sha256sum.txt
69+
# TODO how do we sha256sum the files that will have their names changed during install?
70+
# cd $RPM_BUILD_ROOT/etc/grid-security/certificates
71+
72+
# sha256sum -c cacerts_sha256sum.txt
5973

6074
%files
6175
%defattr(0644,root,root,-)
6276
%dir %attr(0755,root,root) /etc/grid-security/certificates
6377
/etc/grid-security/certificates/*
6478
%doc
6579

80+
%files java
81+
%defattr(0644,root,root,-)
82+
%dir %attr(0755,root,root) /etc/grid-security/certificates
83+
/etc/grid-security/certificates/*
84+
%doc
85+
6686
%changelog
87+
* Thu Nov 9 2023 Matt Westphall <westphall@wisc.edu> - 1.115-2
88+
- Re-add el9 cert changes, create secondary package with original certs (SOFTWARE-5745)
89+
6790
* Tue Oct 31 2023 Mátyás Selmeci <matyas@cs.wisc.edu> - 1.115-1
6891
- Update to IGTF 1.124 (SOFTWARE-5738)
6992

@@ -361,7 +384,7 @@ sha256sum -c cacerts_sha256sum.txt
361384
* Wed Oct 3 2012 Anand Padmanabhan <apadmana@uiuc.edu> - 1.31-2
362385
- CA release corresponding to IGTF 1.50
363386

364-
* Tue Sep 25 2012 Anand Padmanabhan <apadmana@uiuc.edu> - 1.31-1
387+
* Tue Sep 25 2012 Anand Padmanabhan <apadmana@uiuc.edu> - 1.31-1\
365388
- CA release corresponding to IGTF 1.50
366389

367390
* Tue Aug 07 2012 Anand Padmanabhan <apadmana@uiuc.edu> - 1.30-1
@@ -414,4 +437,3 @@ Fix conflicts line.
414437

415438
* Mon Aug 15 2011 Brian Bockelman <bbockelm@cse.unl.edu> - 1.20-1
416439
- Initial version, based on osg-ca-certs spec file.
417-

0 commit comments

Comments
 (0)