MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / SSL

Method SSL

extra/yassl/src/yassl_int.cpp:363–425  ·  view source on GitHub ↗

extract context parameters and store

Source from the content-addressed store, hash-verified

361
362// extract context parameters and store
363SSL::SSL(SSL_CTX* ctx)
364 : secure_(ctx->getMethod()->getVersion(), crypto_.use_random(),
365 ctx->getMethod()->getSide(), ctx->GetCiphers(), ctx,
366 ctx->GetDH_Parms().set_), quietShutdown_(false), has_data_(false)
367{
368 if (int err = crypto_.get_random().GetError()) {
369 SetError(YasslError(err));
370 return;
371 }
372
373 CertManager& cm = crypto_.use_certManager();
374 cm.CopySelfCert(ctx->getCert());
375
376 bool serverSide = secure_.use_parms().entity_ == server_end;
377
378 if (ctx->getKey()) {
379 if (int err = cm.SetPrivateKey(*ctx->getKey())) {
380 SetError(YasslError(err));
381 return;
382 }
383 else if (serverSide && !(ctx->GetCiphers().setSuites_)) {
384 // remove RSA or DSA suites depending on cert key type
385 ProtocolVersion pv = secure_.get_connection().version_;
386
387 bool removeDH = secure_.use_parms().removeDH_;
388 bool removeRSA = false;
389 bool removeDSA = false;
390
391 if (cm.get_keyType() == rsa_sa_algo)
392 removeDSA = true;
393 else
394 removeRSA = true;
395 secure_.use_parms().SetSuites(pv, removeDH, removeRSA, removeDSA);
396 }
397 }
398 else if (serverSide) {
399 SetError(no_key_file);
400 return;
401 }
402
403 if (ctx->getMethod()->verifyPeer())
404 cm.setVerifyPeer();
405 if (ctx->getMethod()->verifyNone())
406 cm.setVerifyNone();
407 if (ctx->getMethod()->failNoCert())
408 cm.setFailNoCert();
409 cm.setVerifyCallback(ctx->getVerifyCallback());
410
411 if (serverSide)
412 crypto_.SetDH(ctx->GetDH_Parms());
413
414 const SSL_CTX::CertList& ca = ctx->GetCA_List();
415 SSL_CTX::CertList::const_iterator first(ca.begin());
416 SSL_CTX::CertList::const_iterator last(ca.end());
417
418 while (first != last) {
419 if (int err = cm.CopyCaCert(*first)) {
420 SetError(YasslError(err));

Callers

nothing calls this directly

Calls 15

YasslErrorEnum · 0.85
getVersionMethod · 0.80
getMethodMethod · 0.80
getSideMethod · 0.80
get_randomMethod · 0.80
CopySelfCertMethod · 0.80
getCertMethod · 0.80
SetPrivateKeyMethod · 0.80
get_keyTypeMethod · 0.80
SetSuitesMethod · 0.80
getVerifyCallbackMethod · 0.80
SetDHMethod · 0.80

Tested by

no test coverage detected