talimat 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. # Tanım: Sertifika Yetki belgeleri, Ortak Anahtar Altyapısı.
  2. # URL: http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1
  3. # Paketçi: milisarge@gmail.com
  4. # Gerekler:
  5. # Grup: temel
  6. isim=ca-certificates
  7. surum=20160110
  8. devir=1
  9. kaynak=(http://downloads.nutyx.org/files/$isim-$surum.tar.gz)
  10. derle() {
  11. mkdir -p $PKG/{bin,etc/ssl}
  12. cp $SRC/ca-bundle.crt $PKG/etc/ssl/
  13. cp -a $SRC/certs $PKG/etc/ssl/certs
  14. # script to reformat a certificate into a form needed by openssl.
  15. cat > $PKG/bin/make-cert.pl << "EOF"
  16. #!/usr/bin/perl -w
  17. # Used to generate PEM encoded files from Mozilla certdata.txt.
  18. # Run as ./mkcrt.pl > certificate.crt
  19. #
  20. # Parts of this script courtesy of RedHat (mkcabundle.pl)
  21. #
  22. # This script modified for use with single file data (tempfile.cer) extracted
  23. # from certdata.txt, taken from the latest version in the Mozilla NSS source.
  24. # mozilla/security/nss/lib/ckfw/builtins/certdata.txt
  25. #
  26. # Authors: DJ Lucas
  27. # Bruce Dubbs
  28. #
  29. # Version 20120211
  30. my $certdata = './tempfile.cer';
  31. open( IN, "cat $certdata|" )
  32. || die "could not open $certdata";
  33. my $incert = 0;
  34. while ( <IN> )
  35. {
  36. if ( /^CKA_VALUE MULTILINE_OCTAL/ )
  37. {
  38. $incert = 1;
  39. open( OUT, "|openssl x509 -text -inform DER -fingerprint" )
  40. || die "could not pipe to openssl x509";
  41. }
  42. elsif ( /^END/ && $incert )
  43. {
  44. close( OUT );
  45. $incert = 0;
  46. print "\n\n";
  47. }
  48. elsif ($incert)
  49. {
  50. my @bs = split( /\\/ );
  51. foreach my $b (@bs)
  52. {
  53. chomp $b;
  54. printf( OUT "%c", oct($b) ) unless $b eq '';
  55. }
  56. }
  57. }
  58. EOF
  59. chmod +x $PKG/bin/make-cert.pl
  60. # script to creates the certificates and a bundle of all the certificates.
  61. cat > $PKG/bin/make-ca.sh << "EOF"
  62. #!/bin/bash
  63. # Begin make-ca.sh
  64. # Script to populate OpenSSL's CApath from a bundle of PEM formatted CAs
  65. #
  66. # The file certdata.txt must exist in the local directory
  67. # Version number is obtained from the version of the data.
  68. #
  69. # Authors: DJ Lucas
  70. # Bruce Dubbs
  71. #
  72. # Version 20120211
  73. certdata="certdata.txt"
  74. if [ ! -r $certdata ]; then
  75. echo "$certdata must be in the local directory"
  76. exit 1
  77. fi
  78. REVISION=$(grep CVS_ID $certdata | cut -f4 -d'$')
  79. if [ -z "${REVISION}" ]; then
  80. echo "$certfile has no 'Revision' in CVS_ID"
  81. exit 1
  82. fi
  83. VERSION=$(echo $REVISION | cut -f2 -d" ")
  84. TEMPDIR=$(mktemp -d)
  85. TRUSTATTRIBUTES="CKA_TRUST_SERVER_AUTH"
  86. BUNDLE="BLFS-ca-bundle-${VERSION}.crt"
  87. CONVERTSCRIPT="/bin/make-cert.pl"
  88. SSLDIR="/etc/ssl"
  89. mkdir "${TEMPDIR}/certs"
  90. # Get a list of staring lines for each cert
  91. CERTBEGINLIST=$(grep -n "^# Certificate" "${certdata}" | cut -d ":" -f1)
  92. # Get a list of ending lines for each cert
  93. CERTENDLIST=`grep -n "^CKA_TRUST_STEP_UP_APPROVED" "${certdata}" | cut -d ":" -f 1`
  94. # Start a loop
  95. for certbegin in ${CERTBEGINLIST}; do
  96. for certend in ${CERTENDLIST}; do
  97. if test "${certend}" -gt "${certbegin}"; then
  98. break
  99. fi
  100. done
  101. # Dump to a temp file with the name of the file as the beginning line number
  102. sed -n "${certbegin},${certend}p" "${certdata}" > "${TEMPDIR}/certs/${certbegin}.tmp"
  103. done
  104. unset CERTBEGINLIST CERTDATA CERTENDLIST certebegin certend
  105. mkdir -p certs
  106. rm certs/* # Make sure the directory is clean
  107. for tempfile in ${TEMPDIR}/certs/*.tmp; do
  108. # Make sure that the cert is trusted...
  109. grep "CKA_TRUST_SERVER_AUTH" "${tempfile}" | \
  110. egrep "TRUST_UNKNOWN|NOT_TRUSTED" > /dev/null
  111. if test "${?}" = "0"; then
  112. # Throw a meaningful error and remove the file
  113. cp "${tempfile}" tempfile.cer
  114. perl ${CONVERTSCRIPT} > tempfile.crt
  115. keyhash=$(openssl x509 -noout -in tempfile.crt -hash)
  116. echo "Certificate ${keyhash} is not trusted! Removing..."
  117. rm -f tempfile.cer tempfile.crt "${tempfile}"
  118. continue
  119. fi
  120. # If execution made it to here in the loop, the temp cert is trusted
  121. # Find the cert data and generate a cert file for it
  122. cp "${tempfile}" tempfile.cer
  123. perl ${CONVERTSCRIPT} > tempfile.crt
  124. keyhash=$(openssl x509 -noout -in tempfile.crt -hash)
  125. mv tempfile.crt "certs/${keyhash}.pem"
  126. rm -f tempfile.cer "${tempfile}"
  127. echo "Created ${keyhash}.pem"
  128. done
  129. # Remove blacklisted files
  130. # MD5 Collision Proof of Concept CA
  131. if test -f certs/8f111d69.pem; then
  132. echo "Certificate 8f111d69 is not trusted! Removing..."
  133. rm -f certs/8f111d69.pem
  134. fi
  135. # Finally, generate the bundle and clean up.
  136. cat certs/*.pem > ${BUNDLE}
  137. rm -r "${TEMPDIR}"
  138. EOF
  139. chmod +x $PKG/bin/make-ca.sh
  140. # script to remove expired certificates from a directory
  141. cat > $PKG/bin/remove-expired-certs.sh << "EOF"
  142. #!/bin/bash
  143. # Begin /bin/remove-expired-certs.sh
  144. #
  145. # Version 20120211
  146. # Make sure the date is parsed correctly on all systems
  147. function mydate()
  148. {
  149. local y=$( echo $1 | cut -d" " -f4 )
  150. local M=$( echo $1 | cut -d" " -f1 )
  151. local d=$( echo $1 | cut -d" " -f2 )
  152. local m
  153. if [ ${d} -lt 10 ]; then d="0${d}"; fi
  154. case $M in
  155. Jan) m="01";;
  156. Feb) m="02";;
  157. Mar) m="03";;
  158. Apr) m="04";;
  159. May) m="05";;
  160. Jun) m="06";;
  161. Jul) m="07";;
  162. Aug) m="08";;
  163. Sep) m="09";;
  164. Oct) m="10";;
  165. Nov) m="11";;
  166. Dec) m="12";;
  167. esac
  168. certdate="${y}${m}${d}"
  169. }
  170. OPENSSL="`which openssl`"
  171. DIR=/etc/ssl/certs
  172. if [ $# -gt 0 ]; then
  173. DIR="$1"
  174. fi
  175. certs=$( find ${DIR} -type f -name "*.pem" -o -name "*.crt" )
  176. today=$( date +%Y%m%d )
  177. for cert in $certs; do
  178. notafter=$( $OPENSSL x509 -enddate -in "${cert}" -noout )
  179. date=$( echo ${notafter} | sed 's/^notAfter=//' )
  180. mydate "$date"
  181. if [ ${certdate} -lt ${today} ]; then
  182. echo "${cert} expired on ${certdate}! Removing..."
  183. rm -f "${cert}"
  184. fi
  185. done
  186. EOF
  187. chmod +x $PKG/bin/remove-expired-certs.sh
  188. }