16 #include <openssl/pem.h>
27 int ret = strncmp (line,
"-----", 5);
28 size_t text_index = 5;
32 size_t begin_or_end_length = strlen (begin_or_end);
33 ret = strncmp (line + text_index, begin_or_end, begin_or_end_length);
34 text_index += begin_or_end_length;
39 ret = line[text_index] -
' ';
45 size_t label_length = strlen (
label);
46 ret = strncmp (line + text_index,
label, label_length);
47 text_index += label_length;
52 ret = strncmp (line + text_index,
"-----", 5);
61 int ret = PTLS_ERROR_PEM_LABEL_NOT_FOUND;
63 ptls_base64_decode_state_t
state;
66 while (BIO_gets (bio, line, 256))
71 ptls_base64_decode_init (&
state);
76 while (ret == 0 && BIO_gets (bio, line, 256))
80 if (
state.status == PTLS_BASE64_DECODE_DONE
81 || (
state.status == PTLS_BASE64_DECODE_IN_PROGRESS
88 ret = PTLS_ERROR_INCORRECT_BASE64;
94 ret = ptls_base64_decode (line, &
state,
buf);
103 size_t list_max,
size_t * nb_objects)
112 while (
count < list_max)
116 ptls_buffer_init (&
buf,
"", 0);
122 if (
buf.off > 0 &&
buf.is_allocated)
130 ptls_buffer_dispose (&
buf);
135 ptls_buffer_dispose (&
buf);
141 if (ret == PTLS_ERROR_PEM_LABEL_NOT_FOUND &&
count > 0)
151 #define PTLS_MAX_CERTS_IN_CONTEXT 16
158 ctx->certificates.list =
160 sizeof (ptls_iovec_t));
162 if (
ctx->certificates.list == NULL)
164 ret = PTLS_ERROR_NO_MEMORY;
171 &
ctx->certificates.count);
181 cert_bio = BIO_new_mem_buf (cert_data, -1);
194 static ptls_openssl_sign_certificate_t sc;
198 key_bio = BIO_new_mem_buf (pk_data, -1);
199 pkey = PEM_read_bio_PrivateKey (key_bio, NULL, NULL, NULL);
205 ptls_openssl_init_sign_certificate (&sc, pkey);
206 EVP_PKEY_free (pkey);
208 ctx->sign_certificate = &sc.super;