Changeset View
Changeset View
Standalone View
Standalone View
protocols/jabber/libjingle/talk/base/opensslidentity.cc
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 158 | OpenSSLKeyPair* OpenSSLKeyPair::Generate() { | |||
---|---|---|---|---|---|
164 | return new OpenSSLKeyPair(pkey); | 164 | return new OpenSSLKeyPair(pkey); | ||
165 | } | 165 | } | ||
166 | 166 | | |||
167 | OpenSSLKeyPair::~OpenSSLKeyPair() { | 167 | OpenSSLKeyPair::~OpenSSLKeyPair() { | ||
168 | EVP_PKEY_free(pkey_); | 168 | EVP_PKEY_free(pkey_); | ||
169 | } | 169 | } | ||
170 | 170 | | |||
171 | void OpenSSLKeyPair::AddReference() { | 171 | void OpenSSLKeyPair::AddReference() { | ||
172 | #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
172 | CRYPTO_add(&pkey_->references, 1, CRYPTO_LOCK_EVP_PKEY); | 173 | CRYPTO_add(&pkey_->references, 1, CRYPTO_LOCK_EVP_PKEY); | ||
174 | #else | ||||
175 | EVP_PKEY_up_ref(pkey_); | ||||
176 | #endif | ||||
177 | | ||||
173 | } | 178 | } | ||
174 | 179 | | |||
175 | #ifdef _DEBUG | 180 | #ifdef _DEBUG | ||
176 | // Print a certificate to the log, for debugging. | 181 | // Print a certificate to the log, for debugging. | ||
177 | static void PrintCert(X509* x509) { | 182 | static void PrintCert(X509* x509) { | ||
178 | BIO* temp_memory_bio = BIO_new(BIO_s_mem()); | 183 | BIO* temp_memory_bio = BIO_new(BIO_s_mem()); | ||
179 | if (!temp_memory_bio) { | 184 | if (!temp_memory_bio) { | ||
180 | LOG_F(LS_ERROR) << "Failed to allocate temporary memory bio"; | 185 | LOG_F(LS_ERROR) << "Failed to allocate temporary memory bio"; | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 266 | std::string OpenSSLCertificate::ToPEMString() const { | |||
270 | char* buffer; | 275 | char* buffer; | ||
271 | BIO_get_mem_data(bio, &buffer); | 276 | BIO_get_mem_data(bio, &buffer); | ||
272 | std::string ret(buffer); | 277 | std::string ret(buffer); | ||
273 | BIO_free(bio); | 278 | BIO_free(bio); | ||
274 | return ret; | 279 | return ret; | ||
275 | } | 280 | } | ||
276 | 281 | | |||
277 | void OpenSSLCertificate::AddReference() { | 282 | void OpenSSLCertificate::AddReference() { | ||
283 | #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
278 | CRYPTO_add(&x509_->references, 1, CRYPTO_LOCK_X509); | 284 | CRYPTO_add(&x509_->references, 1, CRYPTO_LOCK_X509); | ||
285 | #else | ||||
286 | X509_up_ref(x509_); | ||||
287 | #endif | ||||
279 | } | 288 | } | ||
280 | 289 | | |||
281 | OpenSSLIdentity* OpenSSLIdentity::Generate(const std::string& common_name) { | 290 | OpenSSLIdentity* OpenSSLIdentity::Generate(const std::string& common_name) { | ||
282 | OpenSSLKeyPair *key_pair = OpenSSLKeyPair::Generate(); | 291 | OpenSSLKeyPair *key_pair = OpenSSLKeyPair::Generate(); | ||
283 | if (key_pair) { | 292 | if (key_pair) { | ||
284 | OpenSSLCertificate *certificate = | 293 | OpenSSLCertificate *certificate = | ||
285 | OpenSSLCertificate::Generate(key_pair, common_name); | 294 | OpenSSLCertificate::Generate(key_pair, common_name); | ||
286 | if (certificate) | 295 | if (certificate) | ||
Show All 18 Lines |