tocsp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/bin/sh
  2. cmd='../util/shlib_wrap.sh ../apps/openssl'
  3. ocspdir="ocsp-tests"
  4. # 17 December 2012 so we don't get certificate expiry errors.
  5. check_time="-attime 1355875200"
  6. test_ocsp () {
  7. $cmd base64 -d -in $ocspdir/$1 | \
  8. $cmd ocsp -respin - -partial_chain $check_time -trusted_first \
  9. -CAfile $ocspdir/$2 -verify_other $ocspdir/$2 -CApath /dev/null
  10. [ $? != $3 ] && exit 1
  11. }
  12. echo "=== VALID OCSP RESPONSES ==="
  13. echo "NON-DELEGATED; Intermediate CA -> EE"
  14. test_ocsp ND1.ors ND1_Issuer_ICA.pem 0
  15. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  16. test_ocsp ND2.ors ND2_Issuer_Root.pem 0
  17. echo "NON-DELEGATED; Root CA -> EE"
  18. test_ocsp ND3.ors ND3_Issuer_Root.pem 0
  19. echo "DELEGATED; Intermediate CA -> EE"
  20. test_ocsp D1.ors D1_Issuer_ICA.pem 0
  21. echo "DELEGATED; Root CA -> Intermediate CA"
  22. test_ocsp D2.ors D2_Issuer_Root.pem 0
  23. echo "DELEGATED; Root CA -> EE"
  24. test_ocsp D3.ors D3_Issuer_Root.pem 0
  25. echo "=== INVALID SIGNATURE on the OCSP RESPONSE ==="
  26. echo "NON-DELEGATED; Intermediate CA -> EE"
  27. test_ocsp ISOP_ND1.ors ND1_Issuer_ICA.pem 1
  28. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  29. test_ocsp ISOP_ND2.ors ND2_Issuer_Root.pem 1
  30. echo "NON-DELEGATED; Root CA -> EE"
  31. test_ocsp ISOP_ND3.ors ND3_Issuer_Root.pem 1
  32. echo "DELEGATED; Intermediate CA -> EE"
  33. test_ocsp ISOP_D1.ors D1_Issuer_ICA.pem 1
  34. echo "DELEGATED; Root CA -> Intermediate CA"
  35. test_ocsp ISOP_D2.ors D2_Issuer_Root.pem 1
  36. echo "DELEGATED; Root CA -> EE"
  37. test_ocsp ISOP_D3.ors D3_Issuer_Root.pem 1
  38. echo "=== WRONG RESPONDERID in the OCSP RESPONSE ==="
  39. echo "NON-DELEGATED; Intermediate CA -> EE"
  40. test_ocsp WRID_ND1.ors ND1_Issuer_ICA.pem 1
  41. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  42. test_ocsp WRID_ND2.ors ND2_Issuer_Root.pem 1
  43. echo "NON-DELEGATED; Root CA -> EE"
  44. test_ocsp WRID_ND3.ors ND3_Issuer_Root.pem 1
  45. echo "DELEGATED; Intermediate CA -> EE"
  46. test_ocsp WRID_D1.ors D1_Issuer_ICA.pem 1
  47. echo "DELEGATED; Root CA -> Intermediate CA"
  48. test_ocsp WRID_D2.ors D2_Issuer_Root.pem 1
  49. echo "DELEGATED; Root CA -> EE"
  50. test_ocsp WRID_D3.ors D3_Issuer_Root.pem 1
  51. echo "=== WRONG ISSUERNAMEHASH in the OCSP RESPONSE ==="
  52. echo "NON-DELEGATED; Intermediate CA -> EE"
  53. test_ocsp WINH_ND1.ors ND1_Issuer_ICA.pem 1
  54. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  55. test_ocsp WINH_ND2.ors ND2_Issuer_Root.pem 1
  56. echo "NON-DELEGATED; Root CA -> EE"
  57. test_ocsp WINH_ND3.ors ND3_Issuer_Root.pem 1
  58. echo "DELEGATED; Intermediate CA -> EE"
  59. test_ocsp WINH_D1.ors D1_Issuer_ICA.pem 1
  60. echo "DELEGATED; Root CA -> Intermediate CA"
  61. test_ocsp WINH_D2.ors D2_Issuer_Root.pem 1
  62. echo "DELEGATED; Root CA -> EE"
  63. test_ocsp WINH_D3.ors D3_Issuer_Root.pem 1
  64. echo "=== WRONG ISSUERKEYHASH in the OCSP RESPONSE ==="
  65. echo "NON-DELEGATED; Intermediate CA -> EE"
  66. test_ocsp WIKH_ND1.ors ND1_Issuer_ICA.pem 1
  67. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  68. test_ocsp WIKH_ND2.ors ND2_Issuer_Root.pem 1
  69. echo "NON-DELEGATED; Root CA -> EE"
  70. test_ocsp WIKH_ND3.ors ND3_Issuer_Root.pem 1
  71. echo "DELEGATED; Intermediate CA -> EE"
  72. test_ocsp WIKH_D1.ors D1_Issuer_ICA.pem 1
  73. echo "DELEGATED; Root CA -> Intermediate CA"
  74. test_ocsp WIKH_D2.ors D2_Issuer_Root.pem 1
  75. echo "DELEGATED; Root CA -> EE"
  76. test_ocsp WIKH_D3.ors D3_Issuer_Root.pem 1
  77. echo "=== WRONG KEY in the DELEGATED OCSP SIGNING CERTIFICATE ==="
  78. echo "DELEGATED; Intermediate CA -> EE"
  79. test_ocsp WKDOSC_D1.ors D1_Issuer_ICA.pem 1
  80. echo "DELEGATED; Root CA -> Intermediate CA"
  81. test_ocsp WKDOSC_D2.ors D2_Issuer_Root.pem 1
  82. echo "DELEGATED; Root CA -> EE"
  83. test_ocsp WKDOSC_D3.ors D3_Issuer_Root.pem 1
  84. echo "=== INVALID SIGNATURE on the DELEGATED OCSP SIGNING CERTIFICATE ==="
  85. echo "DELEGATED; Intermediate CA -> EE"
  86. test_ocsp ISDOSC_D1.ors D1_Issuer_ICA.pem 1
  87. echo "DELEGATED; Root CA -> Intermediate CA"
  88. test_ocsp ISDOSC_D2.ors D2_Issuer_Root.pem 1
  89. echo "DELEGATED; Root CA -> EE"
  90. test_ocsp ISDOSC_D3.ors D3_Issuer_Root.pem 1
  91. echo "=== WRONG SUBJECT NAME in the ISSUER CERTIFICATE ==="
  92. echo "NON-DELEGATED; Intermediate CA -> EE"
  93. test_ocsp ND1.ors WSNIC_ND1_Issuer_ICA.pem 1
  94. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  95. test_ocsp ND2.ors WSNIC_ND2_Issuer_Root.pem 1
  96. echo "NON-DELEGATED; Root CA -> EE"
  97. test_ocsp ND3.ors WSNIC_ND3_Issuer_Root.pem 1
  98. echo "DELEGATED; Intermediate CA -> EE"
  99. test_ocsp D1.ors WSNIC_D1_Issuer_ICA.pem 1
  100. echo "DELEGATED; Root CA -> Intermediate CA"
  101. test_ocsp D2.ors WSNIC_D2_Issuer_Root.pem 1
  102. echo "DELEGATED; Root CA -> EE"
  103. test_ocsp D3.ors WSNIC_D3_Issuer_Root.pem 1
  104. echo "=== WRONG KEY in the ISSUER CERTIFICATE ==="
  105. echo "NON-DELEGATED; Intermediate CA -> EE"
  106. test_ocsp ND1.ors WKIC_ND1_Issuer_ICA.pem 1
  107. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  108. test_ocsp ND2.ors WKIC_ND2_Issuer_Root.pem 1
  109. echo "NON-DELEGATED; Root CA -> EE"
  110. test_ocsp ND3.ors WKIC_ND3_Issuer_Root.pem 1
  111. echo "DELEGATED; Intermediate CA -> EE"
  112. test_ocsp D1.ors WKIC_D1_Issuer_ICA.pem 1
  113. echo "DELEGATED; Root CA -> Intermediate CA"
  114. test_ocsp D2.ors WKIC_D2_Issuer_Root.pem 1
  115. echo "DELEGATED; Root CA -> EE"
  116. test_ocsp D3.ors WKIC_D3_Issuer_Root.pem 1
  117. echo "=== INVALID SIGNATURE on the ISSUER CERTIFICATE ==="
  118. # Expect success, because we're explicitly trusting the issuer certificate.
  119. echo "NON-DELEGATED; Intermediate CA -> EE"
  120. test_ocsp ND1.ors ISIC_ND1_Issuer_ICA.pem 0
  121. echo "NON-DELEGATED; Root CA -> Intermediate CA"
  122. test_ocsp ND2.ors ISIC_ND2_Issuer_Root.pem 0
  123. echo "NON-DELEGATED; Root CA -> EE"
  124. test_ocsp ND3.ors ISIC_ND3_Issuer_Root.pem 0
  125. echo "DELEGATED; Intermediate CA -> EE"
  126. test_ocsp D1.ors ISIC_D1_Issuer_ICA.pem 0
  127. echo "DELEGATED; Root CA -> Intermediate CA"
  128. test_ocsp D2.ors ISIC_D2_Issuer_Root.pem 0
  129. echo "DELEGATED; Root CA -> EE"
  130. test_ocsp D3.ors ISIC_D3_Issuer_Root.pem 0
  131. echo "ALL OCSP TESTS SUCCESSFUL"
  132. exit 0