Set the private key
| 324 | |
| 325 | // Set the private key |
| 326 | int 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 |
no test coverage detected