summaryrefslogtreecommitdiff
path: root/cpp/test/IceSSL/configuration/Util.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/IceSSL/configuration/Util.h')
-rw-r--r--cpp/test/IceSSL/configuration/Util.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/cpp/test/IceSSL/configuration/Util.h b/cpp/test/IceSSL/configuration/Util.h
new file mode 100644
index 00000000000..a34d17cc87c
--- /dev/null
+++ b/cpp/test/IceSSL/configuration/Util.h
@@ -0,0 +1,37 @@
+
+#include <IceSSL/IceSSL.h>
+
+#ifdef ICE_USE_SECURE_TRANSPORT
+
+#include <IceUtil/FileUtil.h>
+#include <Security/Security.h>
+
+void
+removeKeychain(const std::string& keychainPath, const std::string& password)
+{
+ //
+ // KeyChain path is relative to the current working directory.
+ //
+ std::string path = keychainPath;
+ if(!IceUtilInternal::isAbsolutePath(keychainPath))
+ {
+ std::string cwd;
+ if(IceUtilInternal::getcwd(cwd) == 0)
+ {
+ path = std::string(cwd) + '/' + path;
+ }
+ }
+
+ SecKeychainRef keychain;
+ OSStatus err = SecKeychainOpen(path.c_str(), &keychain);
+ if(err == noErr)
+ {
+ err = SecKeychainUnlock(keychain, password.size(), password.c_str(), true);
+ if(err == noErr)
+ {
+ err = SecKeychainDelete(keychain);
+ }
+ CFRelease(keychain);
+ }
+}
+#endif \ No newline at end of file