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

Method SetPrivateKey

extra/yassl/src/cert_wrapper.cpp:326–356  ·  view source on GitHub ↗

Set the private key

Source from the content-addressed store, hash-verified

324
325// Set the private key
326int CertManager::SetPrivateKey(const x509& key)
327{
328 privateKey_.allocate(key.get_length());
329 privateKey_.assign(key.get_buffer(), key.get_length());
330
331 // set key type
332 if (x509* cert = list_.front()) {
333 TaoCrypt::Source source(cert->get_buffer(), cert->get_length());
334 TaoCrypt::CertDecoder cd(source, false);
335 cd.DecodeToKey();
336 if (int err = cd.GetError().What())
337 return err;
338 if (cd.GetKeyType() == TaoCrypt::RSAk)
339 keyType_ = rsa_sa_algo;
340 else
341 keyType_ = dsa_sa_algo;
342
343 size_t iSz = strlen(cd.GetIssuer()) + 1;
344 size_t sSz = strlen(cd.GetCommonName()) + 1;
345 ASN1_STRING beforeDate, afterDate;
346 beforeDate.data= (unsigned char *) cd.GetBeforeDate();
347 beforeDate.type= cd.GetBeforeDateType();
348 beforeDate.length= strlen((char *) beforeDate.data) + 1;
349 afterDate.data= (unsigned char *) cd.GetAfterDate();
350 afterDate.type= cd.GetAfterDateType();
351 afterDate.length= strlen((char *) afterDate.data) + 1;
352 selfX509_ = NEW_YS X509(cd.GetIssuer(), iSz, cd.GetCommonName(),
353 sSz, &beforeDate, &afterDate);
354 }
355 return 0;
356}
357
358
359// Store OpenSSL type peer's cert

Callers 1

SSLMethod · 0.80

Calls 15

DecodeToKeyMethod · 0.80
GetKeyTypeMethod · 0.80
GetCommonNameMethod · 0.80
GetBeforeDateMethod · 0.80
GetBeforeDateTypeMethod · 0.80
GetAfterDateMethod · 0.80
GetAfterDateTypeMethod · 0.80
X509Class · 0.50
allocateMethod · 0.45
get_lengthMethod · 0.45
assignMethod · 0.45
get_bufferMethod · 0.45

Tested by

no test coverage detected