14 #include <openssl/pem.h> 15 #include <openssl/x509.h> 30 const char*
const default_filename =
"<no filename: not loaded>";
31 const char*
const data_filename =
"<no filename: data uri>";
38 , filename_(default_filename)
56 using namespace CommonUtilities;
80 "(%P|%t) SSL::SignedDocument::load: WARNING: Unsupported URI scheme\n"));
85 std::stringstream msg;
86 msg <<
"SSL::SignedDocument::load: WARNING: Failed to load document supplied " 87 "with URI '" << uri <<
"'";
98 : certs_(sk_X509_new_null())
104 sk_X509_free(certs_);
109 operator bool()
const {
return certs_;}
113 if (sk_X509_push(certs_, certificate.
x509()) != 1) {
124 STACK_OF(
X509)* certs_;
130 : store_(X509_STORE_new())
140 X509_STORE_free(store_);
144 X509_STORE*
store()
const {
return store_; }
145 operator bool()
const {
return store_;}
149 if (X509_STORE_add_cert(store_, certificate.
x509()) != 1) {
172 bio_ = BIO_new(BIO_s_mem());
188 BIO*
bio()
const {
return bio_; }
189 BIO*&
bio() {
return bio_; }
190 operator bool()
const {
return bio_;}
192 bool write(
const void* data,
int dlen)
194 if (BIO_write(bio_, data, dlen) != dlen) {
204 const long size = BIO_get_mem_data(bio_, pp);
231 operator bool()
const {
return doc_; }
239 if (PKCS7_verify(doc_, certs ? certs->certs() : 0, store ? store->
store() : 0,
240 indata.
bio(), outdata.
bio(), flags) != 1) {
264 if (!certs.
push(ca)) {
289 if (!doc.
verify(&certs, 0, bcont, content, PKCS7_TEXT | PKCS7_NOVERIFY | PKCS7_NOINTERN)) {
333 std::ifstream in(path.c_str(), std::ios::binary);
337 "(%P|%t) SignedDocument::PKCS7_from_SMIME_file:" 338 "WARNING: Failed to load file '%C'; '%m'\n",
343 const std::ifstream::pos_type begin = in.tellg();
344 in.seekg(0, std::ios::end);
345 const std::ifstream::pos_type end = in.tellg();
346 in.seekg(0, std::ios::beg);
348 original_.length(static_cast<CORBA::ULong>(end - begin + 1));
349 in.read(reinterpret_cast<char*>(
original_.get_buffer()), end - begin);
353 "(%P|%t) SignedDocument::PKCS7_from_SMIME_file:" 354 "WARNING: Failed to load file '%C'; '%m'\n",
bool verify(const StackOfX509 *certs, const X509Store *store, const Bio &indata, const Bio &outdata, int flags)
bool load(const std::string &uri, DDS::Security::SecurityException &ex)
This URI abstraction is currently naive and only separates the URI scheme on the LHS from the "everyt...
void * memcpy(void *t, const void *s, size_t len)
#define OPENDDS_ASSERT(C)
FILE * fopen(const char *filename, const char *mode)
size_t fread(void *ptr, size_t size, size_t nelems, FILE *fp)
bool push(const Certificate &certificate)
bool add_cert(const Certificate &certificate)
std::string everything_else
const std::string & content() const
sequence< octet > OctetSeq
void load_file(const std::string &path)
bool operator==(const SignedDocument &other) const
bool verify(const Certificate &ca)
virtual ~SignedDocument()
bool write(const void *data, int dlen)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
X509_STORE * store() const
bool set_security_error(DDS::Security::SecurityException &ex, int code, int minor_code, const char *message)
long get_mem_data(char **pp)
STACK_OF(X509) *certs() const
The Internal API and Implementation of OpenDDS.
#define OPENDDS_SSL_LOG_ERR(MSG)