summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2017-01-02 19:47:42 +0100
committerJose <jose@zeroc.com>2017-01-02 19:47:42 +0100
commitde80fa17be82874a6c79f4efaf0e98c5457416c8 (patch)
tree3a8334d464afc5255751d9a8f218ec2a12ceb76f /cpp/src/IceSSL
parentFixed (ICE-7477) - Use native Base64 encode/decode (diff)
downloadice-de80fa17be82874a6c79f4efaf0e98c5457416c8.tar.bz2
ice-de80fa17be82874a6c79f4efaf0e98c5457416c8.tar.xz
ice-de80fa17be82874a6c79f4efaf0e98c5457416c8.zip
Revert "Fixed (ICE-7477) - Use native Base64 encode/decode"
This reverts commit 2df05d130ae51a65f51c593800ad722d533f5df3.
Diffstat (limited to 'cpp/src/IceSSL')
-rw-r--r--cpp/src/IceSSL/SSLEngine.h5
-rwxr-xr-xcpp/src/IceSSL/Util.cpp2
-rw-r--r--cpp/src/IceSSL/Util.h57
3 files changed, 59 insertions, 5 deletions
diff --git a/cpp/src/IceSSL/SSLEngine.h b/cpp/src/IceSSL/SSLEngine.h
index 9a48cd7f707..d9f1a87ca81 100644
--- a/cpp/src/IceSSL/SSLEngine.h
+++ b/cpp/src/IceSSL/SSLEngine.h
@@ -17,7 +17,6 @@
#include <IceUtil/Shared.h>
#include <IceUtil/Mutex.h>
-#include <IceUtil/UniqueRef.h>
#include <Ice/CommunicatorF.h>
#include <Ice/Network.h>
@@ -127,8 +126,8 @@ private:
void parseCiphers(const std::string&);
bool _initialized;
- IceUtil::UniqueRef<CFArrayRef> _certificateAuthorities;
- IceUtil::UniqueRef<CFArrayRef> _chain;
+ UniqueRef<CFArrayRef> _certificateAuthorities;
+ UniqueRef<CFArrayRef> _chain;
SSLProtocol _protocolVersionMax;
SSLProtocol _protocolVersionMin;
diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp
index af02062389b..f262d09979f 100755
--- a/cpp/src/IceSSL/Util.cpp
+++ b/cpp/src/IceSSL/Util.cpp
@@ -14,7 +14,6 @@
#include <IceSSL/Util.h>
#include <IceUtil/FileUtil.h>
-#include <IceUtil/UniqueRef.h>
#include <IceUtil/StringUtil.h>
#include <Ice/Base64.h>
@@ -635,7 +634,6 @@ IceSSL::getCertificateProperty(SecCertificateRef cert, CFTypeRef key)
{
ostringstream os;
os << "IceSSL: error getting property for certificate:\n" << errorToString(err);
- CFRelease(err);
throw CertificateReadException(__FILE__, __LINE__, os.str());
}
diff --git a/cpp/src/IceSSL/Util.h b/cpp/src/IceSSL/Util.h
index ed706a6973e..fc6af1020cc 100644
--- a/cpp/src/IceSSL/Util.h
+++ b/cpp/src/IceSSL/Util.h
@@ -109,6 +109,63 @@ std::string getSslErrors(bool);
#elif defined(ICE_USE_SECURE_TRANSPORT)
+template<typename T>
+class UniqueRef
+{
+public:
+
+ explicit UniqueRef(CFTypeRef ptr = 0) : _ptr((T)ptr)
+ {
+ }
+
+ ~UniqueRef()
+ {
+ if(_ptr != 0)
+ {
+ CFRelease(_ptr);
+ }
+ }
+
+ T release()
+ {
+ T r = _ptr;
+ _ptr = 0;
+ return r;
+ }
+
+ void reset(CFTypeRef ptr = 0)
+ {
+ if(_ptr == ptr)
+ {
+ return;
+ }
+ if(_ptr != 0)
+ {
+ CFRelease(_ptr);
+ }
+ _ptr = (T)ptr;
+ }
+
+ void retain(CFTypeRef ptr)
+ {
+ reset(ptr ? CFRetain(ptr) : ptr);
+ }
+
+ T get() const
+ {
+ return _ptr;
+ }
+
+ operator bool() const
+ {
+ return _ptr != 0;
+ }
+
+private:
+
+ T _ptr;
+};
+
//
// Helper functions to use by Secure Transport.
//