#!/bin/bash if [ "`grep certbundle.h src/ripple/net/impl/RegisterSSLCerts.cpp | wc -l`" -eq "0" ] then cp src/ripple/net/impl/RegisterSSLCerts.cpp src/ripple/net/impl/RegisterSSLCerts.cpp.old perl -i -pe "s/^{/{ #ifdef EMBEDDED_CA_BUNDLE BIO *cbio = BIO_new_mem_buf(ca_bundle.data(), ca_bundle.size()); X509_STORE *cts = SSL_CTX_get_cert_store(ctx.native_handle()); if(!cts || !cbio) JLOG(j.warn()) << \"Failed to create cts\/cbio when loading embedded certs.\"; else { X509_INFO *itmp; int i, count = 0, type = X509_FILETYPE_PEM; STACK_OF(X509_INFO) *inf = PEM_X509_INFO_read_bio(cbio, NULL, NULL, NULL); if (!inf) { BIO_free(cbio); JLOG(j.warn()) << \"Failed to read cbio when loading embedded certs.\"; } else { for (i = 0; i < sk_X509_INFO_num(inf); i++) { itmp = sk_X509_INFO_value(inf, i); if (itmp->x509) { X509_STORE_add_cert(cts, itmp->x509); count++; } if (itmp->crl) { X509_STORE_add_crl(cts, itmp->crl); count++; } } sk_X509_INFO_pop_free(inf, X509_INFO_free); BIO_free(cbio); } } #endif/g" src/ripple/net/impl/RegisterSSLCerts.cpp && sed -i "s/#include /\0\n#include /g" src/ripple/net/impl/RegisterSSLCerts.cpp fi