openssl fixed
This commit is contained in:
@@ -144,13 +144,14 @@ namespace openssl {
|
|||||||
X509(): _x509(X509_new()) {
|
X509(): _x509(X509_new()) {
|
||||||
if (!_x509) throw allocation_failed();
|
if (!_x509) throw allocation_failed();
|
||||||
}
|
}
|
||||||
X509(const X509& o) _x509(0) {
|
X509(const X509& o): _x509(0) {
|
||||||
char* d(0);
|
unsigned char* d(0);
|
||||||
int len(i2d_X509(o._x509, &d));
|
int len(i2d_X509(o._x509, &d));
|
||||||
if (!len) throw x509_copy_failed();
|
if (!len) throw x509_copy_failed();
|
||||||
char* d1(d);
|
const unsigned char* d2(d);
|
||||||
_x509 = d2i_X509(0, &d2, len);
|
_x509 = d2i_X509(0, &d2, len);
|
||||||
if (d2!=d+len || !_x509) throw x509_copy_failed();
|
free(d);
|
||||||
|
if (!_x509) throw x509_copy_failed();
|
||||||
}
|
}
|
||||||
//! Take over OpenSSL allocated certificate.
|
//! Take over OpenSSL allocated certificate.
|
||||||
X509(::X509 *x509): _x509(x509) {
|
X509(::X509 *x509): _x509(x509) {
|
||||||
@@ -162,12 +163,13 @@ namespace openssl {
|
|||||||
X509& operator=(const X509& o) {
|
X509& operator=(const X509& o) {
|
||||||
X509_free(_x509);
|
X509_free(_x509);
|
||||||
_x509 = 0;
|
_x509 = 0;
|
||||||
char* d(0);
|
unsigned char* d(0);
|
||||||
int len(i2d_X509(o._x509, &d));
|
int len(i2d_X509(o._x509, &d));
|
||||||
if (!len) throw x509_copy_failed();
|
if (!len) throw x509_copy_failed();
|
||||||
char* d1(d);
|
const unsigned char* d2(d);
|
||||||
|
free(d);
|
||||||
_x509 = d2i_X509(0, &d2, len);
|
_x509 = d2i_X509(0, &d2, len);
|
||||||
if (d2!=d+len || !_x509) throw x509_copy_failed();
|
if (!_x509) throw x509_copy_failed();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
::X509* _x509;
|
::X509* _x509;
|
||||||
@@ -255,21 +257,22 @@ namespace openssl {
|
|||||||
BIO() {}
|
BIO() {}
|
||||||
~BIO() {
|
~BIO() {
|
||||||
try {
|
try {
|
||||||
close()
|
close();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (!std::uncaught_exception()) throw;
|
if (!std::uncaught_exception()) throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void connect(const std::string& hostPort) {
|
void connect(const std::string& hostPort) {
|
||||||
close();
|
close();
|
||||||
if (_bio = BIO_new_connect(hostPort.c_str()))
|
if (_bio = BIO_new_connect(const_cast<char*>(hostPort.c_str())))
|
||||||
throw bio_connection_failed(hostPort);
|
throw bio_connection_failed(hostPort);
|
||||||
|
// ...
|
||||||
}
|
}
|
||||||
void close() {
|
void close() {
|
||||||
//! @todo tbd
|
//! @todo tbd
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
BIO* _bio;
|
::BIO* _bio;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user