37 const size_t total_size =
make_uint32(0, buf[0], buf[1], buf[2]);
39 if(total_size != buf.size() - 3) {
44 if(max_size > 0 && total_size > max_size) {
45 throw Decoding_Error(
"Certificate chain exceeds policy specified maximum size");
48 const uint8_t* certs = buf.data() + 3;
50 while(
size_t remaining_bytes = buf.data() + buf.size() - certs) {
51 if(remaining_bytes < 3) {
55 const size_t cert_size =
make_uint32(0, certs[0], certs[1], certs[2]);
57 if(remaining_bytes < (3 + cert_size)) {
64 certs += cert_size + 3;
74 if(!m_certs.empty() && m_certs[0].x509_version() != 3) {
75 throw TLS_Exception(Alert::BadCertificate,
"The leaf certificate must be v3");