| 802 | } |
| 803 | |
| 804 | static bool |
| 805 | stapling_cache_response(TS_OCSP_RESPONSE *rsp, certinfo *cinf) |
| 806 | { |
| 807 | unsigned char resp_der[MAX_STAPLING_DER]; |
| 808 | unsigned char *p; |
| 809 | unsigned int resp_derlen; |
| 810 | |
| 811 | p = resp_der; |
| 812 | resp_derlen = i2d_TS_OCSP_RESPONSE(rsp, &p); |
| 813 | |
| 814 | if (resp_derlen == 0) { |
| 815 | Error("stapling_cache_response: cannot decode OCSP response for %s", cinf->certname); |
| 816 | return false; |
| 817 | } |
| 818 | |
| 819 | if (resp_derlen > MAX_STAPLING_DER) { |
| 820 | Error("stapling_cache_response: OCSP response too big (%u bytes) for %s", resp_derlen, cinf->certname); |
| 821 | return false; |
| 822 | } |
| 823 | |
| 824 | ink_mutex_acquire(&cinf->stapling_mutex); |
| 825 | memcpy(cinf->resp_der, resp_der, resp_derlen); |
| 826 | cinf->resp_derlen = resp_derlen; |
| 827 | cinf->is_expire = false; |
| 828 | cinf->expire_time = time(nullptr) + SSLConfigParams::ssl_ocsp_cache_timeout; |
| 829 | ink_mutex_release(&cinf->stapling_mutex); |
| 830 | |
| 831 | Dbg(dbg_ctl_ssl_ocsp, "stapling_cache_response: success to cache response"); |
| 832 | return true; |
| 833 | } |
| 834 | |
| 835 | bool |
| 836 | ssl_stapling_init_cert(SSL_CTX *ctx, X509 *cert, const char *certname, const char *rsp_file) |
no test coverage detected