| 252 | }; |
| 253 | |
| 254 | bool SignedDocument::verify(const Certificate& ca) |
| 255 | { |
| 256 | content_.clear(); |
| 257 | verified_ = false; |
| 258 | |
| 259 | StackOfX509 certs; |
| 260 | if (!certs) { |
| 261 | return false; |
| 262 | } |
| 263 | |
| 264 | if (!certs.push(ca)) { |
| 265 | return false; |
| 266 | } |
| 267 | |
| 268 | Bio filebuf; |
| 269 | if (!filebuf.new_mem()) { |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | if (!filebuf.write(original_.get_buffer(), static_cast<int>(original_.length()))) { |
| 274 | return false; |
| 275 | } |
| 276 | |
| 277 | Bio bcont; |
| 278 | PKCS7Doc doc(SMIME_read_PKCS7(filebuf.bio(), &bcont.bio())); |
| 279 | if (!doc) { |
| 280 | OPENDDS_SSL_LOG_ERR("SMIME_read_PKCS7 failed"); |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | Bio content; |
| 285 | if (!content.new_mem()) { |
| 286 | return false; |
| 287 | } |
| 288 | |
| 289 | if (!doc.verify(&certs, 0, bcont, content, PKCS7_TEXT | PKCS7_NOVERIFY | PKCS7_NOINTERN)) { |
| 290 | return false; |
| 291 | } |
| 292 | |
| 293 | char* p = 0; |
| 294 | long size = content.get_mem_data(&p); |
| 295 | if (size < 0) { |
| 296 | return false; |
| 297 | } |
| 298 | |
| 299 | content_ = std::string(p, static_cast<size_t>(size)); |
| 300 | verified_ = true; |
| 301 | |
| 302 | return verified_; |
| 303 | } |
| 304 | |
| 305 | void SignedDocument::load_file(const std::string& path) |
| 306 | { |
nothing calls this directly
no test coverage detected