MCPcopy Create free account
hub / github.com/apple/foundationdb / loadAsync

Method loadAsync

flow/TLSConfig.actor.cpp:290–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290ACTOR 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
345std::string TLSPolicy::ErrorString(boost::system::error_code e) {
346 char* str = ERR_error_string(e.value(), nullptr);

Callers 1

Net2.actor.cppFile · 0.45

Calls 10

waitForAllFunction · 0.85
fprintfFunction · 0.85
getKeyPathSyncMethod · 0.80
getCAPathSyncMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
isErrorMethod · 0.45
c_strMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected