testss 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/sh
  2. digest='-sha1'
  3. reqcmd="../util/shlib_wrap.sh ../apps/openssl req"
  4. x509cmd="../util/shlib_wrap.sh ../apps/openssl x509 $digest"
  5. verifycmd="../util/shlib_wrap.sh ../apps/openssl verify"
  6. dummycnf="../apps/openssl.cnf"
  7. CAkey="keyCA.ss"
  8. CAcert="certCA.ss"
  9. CAserial="certCA.srl"
  10. CAreq="reqCA.ss"
  11. CAconf="CAss.cnf"
  12. CAreq2="req2CA.ss" # temp
  13. Uconf="Uss.cnf"
  14. Ukey="keyU.ss"
  15. Ureq="reqU.ss"
  16. Ucert="certU.ss"
  17. Dkey="keyD.ss"
  18. Dreq="reqD.ss"
  19. Dcert="certD.ss"
  20. Ekey="keyE.ss"
  21. Ereq="reqE.ss"
  22. Ecert="certE.ss"
  23. P1conf="P1ss.cnf"
  24. P1key="keyP1.ss"
  25. P1req="reqP1.ss"
  26. P1cert="certP1.ss"
  27. P1intermediate="tmp_intP1.ss"
  28. P2conf="P2ss.cnf"
  29. P2key="keyP2.ss"
  30. P2req="reqP2.ss"
  31. P2cert="certP2.ss"
  32. P2intermediate="tmp_intP2.ss"
  33. echo string to make the random number generator think it has entropy >> ./.rnd
  34. req_dsa='-newkey dsa:../apps/dsa1024.pem'
  35. if ../util/shlib_wrap.sh ../apps/openssl no-rsa >/dev/null; then
  36. req_new=$req_dsa
  37. else
  38. req_new='-new'
  39. fi
  40. echo make cert request
  41. $reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new || exit 1
  42. echo convert request into self-signed cert
  43. $x509cmd -CAcreateserial -in $CAreq -days 30 -req -out $CAcert -signkey $CAkey -extfile $CAconf -extensions v3_ca >err.ss || exit 1
  44. echo convert cert into a cert request
  45. $x509cmd -in $CAcert -x509toreq -signkey $CAkey -out $CAreq2 >err.ss || exit 1
  46. echo verify request 1
  47. $reqcmd -config $dummycnf -verify -in $CAreq -noout || exit 1
  48. echo verify request 1
  49. $reqcmd -config $dummycnf -verify -in $CAreq2 -noout || exit 1
  50. echo verify signature
  51. $verifycmd -CAfile $CAcert $CAcert || exit 1
  52. echo make a user cert request
  53. $reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss || exit 1
  54. echo sign user cert request
  55. $x509cmd -CAcreateserial -in $Ureq -days 30 -req -out $Ucert -CA $CAcert -CAkey $CAkey -CAserial $CAserial -extfile $Uconf -extensions v3_ee >err.ss || exit 1
  56. $verifycmd -CAfile $CAcert $Ucert || exit 1
  57. echo Certificate details
  58. $x509cmd -subject -issuer -startdate -enddate -noout -in $Ucert || exit 1
  59. if ../util/shlib_wrap.sh ../apps/openssl no-dsa >/dev/null; then
  60. echo skipping DSA certificate creation
  61. else
  62. echo make a DSA user cert request
  63. CN2="DSA Certificate" $reqcmd -config $Uconf -out $Dreq -keyout $Dkey $req_dsa >err.ss || exit 1
  64. echo sign DSA user cert request
  65. $x509cmd -CAcreateserial -in $Dreq -days 30 -req -out $Dcert -CA $CAcert -CAkey $CAkey -CAserial $CAserial -extfile $Uconf -extensions v3_ee_dsa >err.ss || exit 1
  66. $verifycmd -CAfile $CAcert $Dcert || exit 1
  67. echo DSA Certificate details
  68. $x509cmd -subject -issuer -startdate -enddate -noout -in $Dcert || exit 1
  69. fi
  70. if ../util/shlib_wrap.sh ../apps/openssl no-ec >/dev/null; then
  71. echo skipping ECDSA/ECDH certificate creation
  72. else
  73. echo make an ECDSA/ECDH user cert request
  74. ../util/shlib_wrap.sh ../apps/openssl ecparam -name P-256 -out ecp.ss || exit 1
  75. CN2="ECDSA Certificate" $reqcmd -config $Uconf -out $Ereq -keyout $Ekey -newkey ec:ecp.ss >err.ss || exit 1
  76. echo sign ECDSA/ECDH user cert request
  77. $x509cmd -CAcreateserial -in $Ereq -days 30 -req -out $Ecert -CA $CAcert -CAkey $CAkey -CAserial $CAserial -extfile $Uconf -extensions v3_ee_ec >err.ss || exit 1
  78. $verifycmd -CAfile $CAcert $Ecert || exit 1
  79. echo ECDSA Certificate details
  80. $x509cmd -subject -issuer -startdate -enddate -noout -in $Ecert || exit 1
  81. fi
  82. echo make a proxy cert request
  83. $reqcmd -config $P1conf -out $P1req -keyout $P1key $req_new >err.ss || exit 1
  84. echo sign proxy with user cert
  85. $x509cmd -CAcreateserial -in $P1req -days 30 -req -out $P1cert -CA $Ucert -CAkey $Ukey -extfile $P1conf -extensions v3_proxy >err.ss || exit 1
  86. cat $Ucert > $P1intermediate
  87. $verifycmd -CAfile $CAcert -untrusted $P1intermediate $P1cert
  88. echo Certificate details
  89. $x509cmd -subject -issuer -startdate -enddate -noout -in $P1cert
  90. echo make another proxy cert request
  91. $reqcmd -config $P2conf -out $P2req -keyout $P2key $req_new >err.ss || exit 1
  92. echo sign second proxy cert request with the first proxy cert
  93. $x509cmd -CAcreateserial -in $P2req -days 30 -req -out $P2cert -CA $P1cert -CAkey $P1key -extfile $P2conf -extensions v3_proxy >err.ss || exit 1
  94. echo Certificate details
  95. cat $Ucert $P1cert > $P2intermediate
  96. $verifycmd -CAfile $CAcert -untrusted $P2intermediate $P2cert
  97. $x509cmd -subject -issuer -startdate -enddate -noout -in $P2cert
  98. echo The generated CA certificate is $CAcert
  99. echo The generated CA private key is $CAkey
  100. echo The generated user certificate is $Ucert
  101. echo The generated user private key is $Ukey
  102. echo The first generated proxy certificate is $P1cert
  103. echo The first generated proxy private key is $P1key
  104. echo The second generated proxy certificate is $P2cert
  105. echo The second generated proxy private key is $P2key
  106. /bin/rm err.ss
  107. exit 0