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