7908df
#global prever rc1
2ccaac
Summary: Software version of a PKCS#11 Hardware Security Module
2ccaac
Name: softhsm
7908df
Version: 2.1.0
9b9f54
Release: %{?prever:0.}3%{?prever:.%{prever}}%{?dist}
2ccaac
License: BSD
2ccaac
Url: http://www.opendnssec.org/
7908df
Source: http://dist.opendnssec.org/source/%{?prever:testing/}%{name}-%{version}.tar.gz
7908df
Source1: http://dist.opendnssec.org/source/%{?prever:testing/}%{name}-%{version}.tar.gz.sig
f20abe
Source2: softhsm.module
2ccaac
# taken from coolkey which is not build on all arches we build on
f20abe
Source3: softhsm2-pk11install.c
9b9f54
Patch1: 0001-use-warning-messages-for-failing-to-enumerate-store.patch
9b9f54
Patch2: 0002-Issue-239-Crash-on-module-unload-with-OpenSSL.patch
7908df
2ccaac
Group: Applications/System
7908df
# which version of openssl contains backport of aes wrapping support?
f20abe
BuildRequires: openssl-devel >= 1.0.1e-42.el7_1.2, sqlite-devel >= 3.4.2, cppunit-devel
2ccaac
BuildRequires: gcc-c++, pkgconfig, p11-kit-devel, nss-devel
2ccaac
2ccaac
Requires(pre): shadow-utils
2ccaac
Requires: p11-kit, nss-tools
f20abe
Requires: openssl-libs >= 1.0.1e-42.el7_1.2
2ccaac
2ccaac
%global _hardened_build 1
2ccaac
2ccaac
%global softhsm_module "SoftHSM PKCS #11 Module"
2ccaac
%global nssdb %{_sysconfdir}/pki/nssdb
2ccaac
2ccaac
%description
7908df
NOTE: This package is only suported for use with Identity Management.
2ccaac
2ccaac
OpenDNSSEC is providing a software implementation of a generic
2ccaac
cryptographic device with a PKCS#11 interface, the SoftHSM. SoftHSM is
2ccaac
designed to meet the requirements of OpenDNSSEC, but can also work together
2ccaac
with other cryptographic products because of the PKCS#11 interface.
2ccaac
2ccaac
%package devel
2ccaac
Summary: Development package of softhsm that includes the header files
2ccaac
Group: Development/Libraries
2ccaac
Requires: %{name} = %{version}-%{release}, openssl-devel, sqlite-devel
7908df
%if 0%{?prever:1}
7908df
BuildRequires: autoconf, libtool, automake
7908df
%endif
2ccaac
2ccaac
%description devel
2ccaac
The devel package contains the libsofthsm include files
2ccaac
2ccaac
%prep
9b9f54
%autosetup -n %{name}-%{version}%{?prever} -p1
7908df
7908df
%if 0%{?prever:1}
7908df
autoreconf -fiv
7908df
%endif
7908df
2ccaac
# remove softhsm/ subdir auto-added to --libdir
2ccaac
sed -i "s:full_libdir/softhsm:full_libdir:g" configure
7908df
%if 0%{?prever:1}
7908df
sed -i 's:^full_libdir=":#full_libdir=":g' configure.ac
7908df
%endif
2ccaac
sed -i "s:libdir)/@PACKAGE@:libdir):" Makefile.in
2ccaac
2ccaac
%build
f20abe
%configure --libdir=%{_libdir}/pkcs11 --with-openssl=%{_prefix} --enable-ecc --disable-gost \
2ccaac
           --with-migrate --enable-visibility
2ccaac
2ccaac
make %{?_smp_mflags}
2ccaac
# install our copy of pk11install taken from coolkey package
f20abe
cp %{SOURCE3} .
2ccaac
gcc $(pkg-config --cflags nss) %{optflags} -c softhsm2-pk11install.c
2ccaac
gcc $(pkg-config --libs nss) -lpthread  -lsoftokn3 -ldl -lz %{optflags} softhsm2-pk11install.o -o softhsm2-pk11install
2ccaac
2ccaac
%check
2ccaac
make check
2ccaac
2ccaac
%install
2ccaac
rm -rf %{buildroot}
2ccaac
make DESTDIR=%{buildroot} install
f20abe
install -D %{SOURCE2} %{buildroot}/%{_datadir}/p11-kit/modules/softhsm.module
2ccaac
2ccaac
rm %{buildroot}/%{_sysconfdir}/softhsm2.conf.sample
2ccaac
rm -f %{buildroot}/%{_libdir}/pkcs11/*a
2ccaac
mkdir -p %{buildroot}%{_includedir}/softhsm
2ccaac
cp src/lib/*.h %{buildroot}%{_includedir}/softhsm
2ccaac
mkdir -p %{buildroot}/%{_sharedstatedir}/softhsm/tokens
2ccaac
install -m0755 -D softhsm2-pk11install %{buildroot}/%{_bindir}/softhsm2-pk11install
2ccaac
7908df
# rhbz#1272423 NSS needs it to be in the search path too
7908df
( cd  %{buildroot}/%{_libdir} ; ln -s pkcs11/libsofthsm2.so)
7908df
2ccaac
%files
2ccaac
%config(noreplace) %{_sysconfdir}/softhsm2.conf
2ccaac
%{_bindir}/*
2ccaac
%{_libdir}/pkcs11/libsofthsm2.so
7908df
%{_libdir}/libsofthsm2.so
2ccaac
%attr(0664,root,root) %{_datadir}/p11-kit/modules/softhsm.module
2ccaac
%attr(0770,ods,ods) %dir %{_sharedstatedir}/softhsm
2ccaac
%attr(0770,ods,ods) %dir %{_sharedstatedir}/softhsm/tokens
2ccaac
%doc LICENSE README.md NEWS
2ccaac
%{_mandir}/*/*
2ccaac
2ccaac
%files devel
2ccaac
%attr(0755,root,root) %dir %{_includedir}/softhsm
2ccaac
%{_includedir}/softhsm/*.h
2ccaac
2ccaac
%pre
2ccaac
getent group ods >/dev/null || groupadd -r ods
2ccaac
getent passwd ods >/dev/null || \
7908df
    useradd -r -g ods -d %{_sharedstatedir}/softhsm -s /sbin/nologin \
2ccaac
    -c "softhsm private keys owner" ods
2ccaac
exit 0
2ccaac
2ccaac
%post
2ccaac
isThere=`modutil -rawlist -dbdir %{nssdb} | grep %{softhsm_module} || echo NO`
2ccaac
if [ "$isThere" == "NO" ]; then
2ccaac
      softhsm2-pk11install -p %{nssdb} 'name=%{softhsm_module} library=libsofthsm2.so'
2ccaac
fi
2ccaac
2ccaac
if [ $1 -eq 0 ]; then
2ccaac
   modutil -delete %{softhsm_module} -dbdir %{nssdb} -force || :
2ccaac
fi
2ccaac
2ccaac
%changelog
9b9f54
* Tue Mar 31 2020 Alexander Bokovoy <abokovoy@redhat.com> - 2.1.0-3
9b9f54
- Resolves: rhbz#1507409 ObjectStore.cpp(59): Failed to enumerate object store in /var/lib/softhsm/tokens/
9b9f54
- Resolves: rhbz#1540010 gnome-settings-daemon: gnome-settings-daemon killed by SIGSEGV
9b9f54
7908df
* Thu Jun 23 2016 Paul Wouters <pwouters@redhat.com> - 2.1.0-2
7908df
- Re-add note this package is only supported for IdM
7908df
7908df
* Wed Jun 22 2016 Paul Wouters <pwouters@redhat.com> - 2.1.0-1
7908df
- Resolves: rhbz#1281704 Rebase to softhsm 2.1.0, fix search path, fix writing trusted/CA certs
7908df
f20abe
* Fri Jun 26 2015 Petr Spacek <pspacek@redhat.com> - 2.0.0rc1-3
f20abe
- Dependency on OpenSSL libraries with fix for bug #1193942 was added.
f20abe
f20abe
* Mon Jun 01 2015 Petr Spacek <pspacek@redhat.com> - 2.0.0rc1-1
f20abe
- Resolves: rhbz#1193892 Rebase to latest upstream version
f20abe
- i686/ppc/s390 architectures are now included in the build
f20abe
2ccaac
* Tue Nov 11 2014 Paul Wouters <pwouters@redhat.com> - 2.0.0b1-4
2ccaac
- Resolves: rhbz#1117157 Add warning to package description
2ccaac
2ccaac
* Tue Sep 30 2014 Paul Wouters <pwouters@redhat.com> - 2.0.0b1-3
2ccaac
- Fix softhsm2-pk11install buid and post call
2ccaac
- Do not use --with-objectstore-backend-db (causes issues on i686)
2ccaac
2ccaac
* Tue Sep 23 2014 Paul Wouters <pwouters@redhat.com> - 2.0.0b1-2
2ccaac
- Change install directory to /usr/lib*/pkcs11/
2ccaac
- Install pkcs11 module file
2ccaac
- Use official upstream tar ball
2ccaac
- Create ods user to own softhsm/token files
2ccaac
- Enable migration tools (for epel6 softhsm-v1 installs)
2ccaac
- Require p11-kit, nss-tools, for SoftHSM PKCS #11 Module file
2ccaac
- Copy pk11install.c from coolkey package which is not built on all arches
2ccaac
- Enable hardened build
2ccaac
- Add upstream official source url
2ccaac
- Add devel package
2ccaac
- Excluding i686/ppc (make check fails and we are a leave package)
2ccaac
- (thanks to Petr for jumping in for the initial build while I was too busy)
2ccaac
2ccaac
* Thu Sep 11 2014 Petr Spacek <pspacek@redhat.com> - 2.0.0b1-1
2ccaac
- Initial package for RHEL