+ BUF_MEM *bptr;
+ X509 *cert;
+ gss_buffer_desc tmp;
+
+ bio = BIO_new_mem_buf(caCertificate, -1);
+ if (bio == NULL) {
+ major = GSS_S_FAILURE;
+ *minor = ENOMEM;
+ goto cleanup;
+ }
+ cert = PEM_read_bio_X509(bio, NULL, NULL, NULL);
+ if (cert == NULL) {
+ major = GSS_S_FAILURE;
+ *minor = ENOMEM;
+ goto cleanup;
+ }
+ BIO_free(bio);
+ bio = BIO_new(BIO_s_mem());
+ if (i2d_X509_bio(bio, cert) < 0) {
+ major = GSS_S_FAILURE;
+ *minor = ENOMEM; /* TODO */
+ goto cleanup;
+ }
+ BIO_get_mem_ptr(bio, &bptr);
+ tmp.value = bptr->data;
+ tmp.length = bptr->length;
+ major = duplicateBuffer(minor, &tmp, &cred->caCertificateBlob);
+ if (major != GSS_S_COMPLETE) {
+ goto cleanup;
+ }
+ BIO_free(bio);
+ makeStringBufferOrCleanup("blob://ca-cert", &cred->caCertificate);