+%if %{with tests}
+install -d pld-tests
+cd pld-tests
+
+# check for duplicates (to avoid X509_STORE_add_cert "cert already in hash table" problem)
+cat $RPM_BUILD_ROOT/%{certsdir}/ca-certificates.crt | awk '/BEGIN/ { i++; } /BEGIN/, /END/ { print > i ".extracted.crt" }'
+for cert in *.extracted.crt; do
+ openssl x509 -in "$cert" -noout -sha1 -fingerprint > "$cert.fingerprint"
+done
+DUPLICATES=$(sort *.fingerprint | uniq -c | sort -nr | awk ' { if ($1 != 1) { print $0; } } ')
+if [ -n "$DUPLICATES" ]; then
+ echo -e "\n\nFound duplicates for certificates (count, type, fingerprint):\n\n$DUPLICATES\n\nFailing..."
+ exit 1
+fi
+cd ..
+%endif
+