| 265 | } |
| 266 | |
| 267 | Status ExampleTlsCertificates(std::vector<CertKeyPair>* out) { |
| 268 | ARROW_ASSIGN_OR_RAISE(auto root, GetTestResourceRoot()); |
| 269 | |
| 270 | *out = std::vector<CertKeyPair>(); |
| 271 | for (int i = 0; i < 2; i++) { |
| 272 | try { |
| 273 | std::stringstream cert_path; |
| 274 | cert_path << root << "/flight/cert" << i << ".pem"; |
| 275 | std::stringstream key_path; |
| 276 | key_path << root << "/flight/cert" << i << ".key"; |
| 277 | |
| 278 | std::ifstream cert_file(cert_path.str()); |
| 279 | if (!cert_file) { |
| 280 | return Status::IOError("Could not open certificate: " + cert_path.str()); |
| 281 | } |
| 282 | std::stringstream cert; |
| 283 | cert << cert_file.rdbuf(); |
| 284 | |
| 285 | std::ifstream key_file(key_path.str()); |
| 286 | if (!key_file) { |
| 287 | return Status::IOError("Could not open key: " + key_path.str()); |
| 288 | } |
| 289 | std::stringstream key; |
| 290 | key << key_file.rdbuf(); |
| 291 | |
| 292 | out->push_back(CertKeyPair{cert.str(), key.str()}); |
| 293 | } catch (const std::ifstream::failure& e) { |
| 294 | return Status::IOError(e.what()); |
| 295 | } |
| 296 | } |
| 297 | return Status::OK(); |
| 298 | } |
| 299 | |
| 300 | Status ExampleTlsCertificateRoot(CertKeyPair* out) { |
| 301 | ARROW_ASSIGN_OR_RAISE(auto path, GetTestResourcePath("flight/root-ca.pem")); |