| 124 | } |
| 125 | |
| 126 | static void ssl_log_cert_error(const char *file, int line, int level, |
| 127 | apr_status_t rv, const server_rec *s, |
| 128 | const conn_rec *c, const request_rec *r, |
| 129 | apr_pool_t *p, const X509 *cert, const char *format, |
| 130 | va_list ap) |
| 131 | { |
| 132 | char buf[HUGE_STRING_LEN]; |
| 133 | int msglen, n; |
| 134 | char *name; |
| 135 | |
| 136 | msglen = apr_vsnprintf(buf, sizeof buf, format, ap); |
| 137 | |
| 138 | if (cert) { |
| 139 | BIO *bio = BIO_new(BIO_s_mem()); |
| 140 | |
| 141 | if (bio) { |
| 142 | /* |
| 143 | * Limit the maximum length of the subject and issuer DN strings |
| 144 | * in the log message. 300 characters should always be sufficient |
| 145 | * for holding both the timestamp, module name, pid etc. stuff |
| 146 | * at the beginning of the line and the trailing information about |
| 147 | * serial, notbefore and notafter. |
| 148 | */ |
| 149 | int maxdnlen = (HUGE_STRING_LEN - msglen - 300) / 2; |
| 150 | |
| 151 | BIO_puts(bio, " [subject: "); |
| 152 | name = modssl_X509_NAME_to_string(p, X509_get_subject_name(cert), |
| 153 | maxdnlen); |
| 154 | if (!strIsEmpty(name)) { |
| 155 | BIO_puts(bio, name); |
| 156 | } else { |
| 157 | BIO_puts(bio, "-empty-"); |
| 158 | } |
| 159 | |
| 160 | BIO_puts(bio, " / issuer: "); |
| 161 | name = modssl_X509_NAME_to_string(p, X509_get_issuer_name(cert), |
| 162 | maxdnlen); |
| 163 | if (!strIsEmpty(name)) { |
| 164 | BIO_puts(bio, name); |
| 165 | } else { |
| 166 | BIO_puts(bio, "-empty-"); |
| 167 | } |
| 168 | |
| 169 | BIO_puts(bio, " / serial: "); |
| 170 | if (i2a_ASN1_INTEGER(bio, X509_get0_serialNumber(cert)) == -1) |
| 171 | BIO_puts(bio, "(ERROR)"); |
| 172 | |
| 173 | BIO_puts(bio, " / notbefore: "); |
| 174 | ASN1_TIME_print(bio, X509_get0_notBefore(cert)); |
| 175 | |
| 176 | BIO_puts(bio, " / notafter: "); |
| 177 | ASN1_TIME_print(bio, X509_get0_notAfter(cert)); |
| 178 | |
| 179 | BIO_puts(bio, "]"); |
| 180 | |
| 181 | n = BIO_read(bio, buf + msglen, sizeof buf - msglen - 1); |
| 182 | if (n > 0) |
| 183 | buf[msglen + n] = '\0'; |
no test coverage detected