| 288 | } |
| 289 | |
| 290 | ACTOR Future<LoadedTLSConfig> TLSConfig::loadAsync(const TLSConfig* self) { |
| 291 | state LoadedTLSConfig loaded; |
| 292 | state std::vector<Future<Void>> reads; |
| 293 | |
| 294 | state int32_t certIdx = -1; |
| 295 | state int32_t keyIdx = -1; |
| 296 | state int32_t caIdx = -1; |
| 297 | |
| 298 | state std::string certPath = self->getCertificatePathSync(); |
| 299 | if (certPath.size()) { |
| 300 | reads.push_back(readEntireFile(certPath, &loaded.tlsCertBytes)); |
| 301 | certIdx = reads.size() - 1; |
| 302 | } else { |
| 303 | loaded.tlsCertBytes = self->tlsCertBytes; |
| 304 | } |
| 305 | |
| 306 | state std::string keyPath = self->getKeyPathSync(); |
| 307 | if (keyPath.size()) { |
| 308 | reads.push_back(readEntireFile(keyPath, &loaded.tlsKeyBytes)); |
| 309 | keyIdx = reads.size() - 1; |
| 310 | } else { |
| 311 | loaded.tlsKeyBytes = self->tlsKeyBytes; |
| 312 | } |
| 313 | |
| 314 | state std::string CAPath = self->getCAPathSync(); |
| 315 | if (CAPath.size()) { |
| 316 | reads.push_back(readEntireFile(CAPath, &loaded.tlsCABytes)); |
| 317 | caIdx = reads.size() - 1; |
| 318 | } else { |
| 319 | loaded.tlsCABytes = self->tlsCABytes; |
| 320 | } |
| 321 | |
| 322 | try { |
| 323 | wait(waitForAll(reads)); |
| 324 | } catch (Error& e) { |
| 325 | if (certIdx != -1 && reads[certIdx].isError()) { |
| 326 | fprintf(stderr, "Failure reading TLS Certificate [%s]: %s\n", certPath.c_str(), e.what()); |
| 327 | } else if (keyIdx != -1 && reads[keyIdx].isError()) { |
| 328 | fprintf(stderr, "Failure reading TLS Key [%s]: %s\n", keyPath.c_str(), e.what()); |
| 329 | } else if (caIdx != -1 && reads[caIdx].isError()) { |
| 330 | fprintf(stderr, "Failure reading TLS Key [%s]: %s\n", CAPath.c_str(), e.what()); |
| 331 | } else { |
| 332 | fprintf(stderr, "Failure reading TLS needed file: %s\n", e.what()); |
| 333 | } |
| 334 | |
| 335 | throw; |
| 336 | } |
| 337 | |
| 338 | loaded.tlsPassword = self->tlsPassword; |
| 339 | loaded.tlsVerifyPeers = self->tlsVerifyPeers; |
| 340 | loaded.endpointType = self->endpointType; |
| 341 | |
| 342 | return loaded; |
| 343 | } |
| 344 | |
| 345 | std::string TLSPolicy::ErrorString(boost::system::error_code e) { |
| 346 | char* str = ERR_error_string(e.value(), nullptr); |
no test coverage detected