if (BIO_read_filename(in, path) <= 0)
goto end;
- /* Read Certificate */
- ckch->cert = PEM_read_bio_X509_AUX(in, NULL, NULL, NULL);
- if (ckch->cert == NULL) {
- memprintf(err, "%sunable to load certificate from file '%s'.\n",
- err && *err ? *err : "", path);
- goto end;
- }
-
/* Read Private Key */
ckch->key = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL);
if (ckch->key == NULL) {
goto end;
}
+ /* Seek back to beginning of file */
+ BIO_reset(in);
+
+ /* Read Certificate */
+ ckch->cert = PEM_read_bio_X509_AUX(in, NULL, NULL, NULL);
+ if (ckch->cert == NULL) {
+ memprintf(err, "%sunable to load certificate from file '%s'.\n",
+ err && *err ? *err : "", path);
+ goto end;
+ }
+
/* Read Certificate Chain */
while ((ca = PEM_read_bio_X509(in, NULL, NULL, NULL))) {
/* Grow the chain certs */