summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL/Context.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2006-04-19 23:52:09 +0000
committerMark Spruiell <mes@zeroc.com>2006-04-19 23:52:09 +0000
commit6130cbddb8d92c3becd578e8be26da7cd8e76891 (patch)
treec2c6451987ce4d251d948bf4d0e7e6cd96674a7a /cpp/src/IceSSL/Context.cpp
parentminor fix (diff)
downloadice-6130cbddb8d92c3becd578e8be26da7cd8e76891.tar.bz2
ice-6130cbddb8d92c3becd578e8be26da7cd8e76891.tar.xz
ice-6130cbddb8d92c3becd578e8be26da7cd8e76891.zip
moving checkPath so that PluginI can use it for IceSSL.Random
Diffstat (limited to 'cpp/src/IceSSL/Context.cpp')
-rw-r--r--cpp/src/IceSSL/Context.cpp60
1 files changed, 5 insertions, 55 deletions
diff --git a/cpp/src/IceSSL/Context.cpp b/cpp/src/IceSSL/Context.cpp
index 1988f526116..5dd8a1fb99c 100644
--- a/cpp/src/IceSSL/Context.cpp
+++ b/cpp/src/IceSSL/Context.cpp
@@ -16,16 +16,6 @@
#include <Ice/LoggerUtil.h>
#include <Ice/Properties.h>
-#ifdef _WIN32
-# include <direct.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-# define S_ISDIR(mode) ((mode) & _S_IFDIR)
-# define S_ISREG(mode) ((mode) & _S_IFREG)
-#else
-# include <sys/stat.h>
-#endif
-
#include <openssl/x509v3.h>
#include <openssl/err.h>
@@ -198,7 +188,7 @@ IceSSL::Context::Context(const InstancePtr& instance, SSL_CTX* ctx) :
const char* dir = 0;
if(!caFile.empty())
{
- if(!checkPath(caFile, false))
+ if(!checkPath(caFile, _defaultDir, false))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "IceSSL: CA certificate file not found:\n" + caFile;
@@ -208,7 +198,7 @@ IceSSL::Context::Context(const InstancePtr& instance, SSL_CTX* ctx) :
}
if(!caDir.empty())
{
- if(!checkPath(caDir, true))
+ if(!checkPath(caDir, _defaultDir, true))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "IceSSL: CA certificate directory not found:\n" + caDir;
@@ -282,7 +272,7 @@ IceSSL::Context::Context(const InstancePtr& instance, SSL_CTX* ctx) :
for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
{
string file = *p;
- if(!checkPath(file, false))
+ if(!checkPath(file, _defaultDir, false))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "IceSSL: certificate file not found:\n" + file;
@@ -347,7 +337,7 @@ IceSSL::Context::Context(const InstancePtr& instance, SSL_CTX* ctx) :
for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
{
string file = *p;
- if(!checkPath(file, false))
+ if(!checkPath(file, _defaultDir, false))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "IceSSL: key file not found:\n" + file;
@@ -453,7 +443,7 @@ IceSSL::Context::Context(const InstancePtr& instance, SSL_CTX* ctx) :
if(keyLength > 0)
{
string file = p->second;
- if(!checkPath(file, false))
+ if(!checkPath(file, _defaultDir, false))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "IceSSL: DH parameter file not found:\n" + file;
@@ -755,46 +745,6 @@ IceSSL::Context::traceConnection(SSL* ssl, bool incoming)
out << IceInternal::fdToString(SSL_get_fd(ssl));
}
-bool
-IceSSL::Context::checkPath(string& path, bool dir)
-{
- //
- // Check if file exists. If not, try prepending the default
- // directory and check again. If the file is found, the
- // string argument is modified and true is returned. Otherwise
- // false is returned.
- //
-#ifdef _WIN32
- struct _stat st;
- int err = ::_stat(path.c_str(), &st);
-#else
- struct stat st;
- int err = ::stat(path.c_str(), &st);
-#endif
- if(err == 0)
- {
- return dir ? S_ISDIR(st.st_mode) != 0 : S_ISREG(st.st_mode) != 0;
- }
-
- if(!_defaultDir.empty())
- {
-#ifdef _WIN32
- string s = _defaultDir + "\\" + path;
- err = ::_stat(s.c_str(), &st);
-#else
- string s = _defaultDir + "/" + path;
- err = ::stat(s.c_str(), &st);
-#endif
- if(err == 0 && ((!dir && S_ISREG(st.st_mode)) || (dir && S_ISDIR(st.st_mode))))
- {
- path = s;
- return true;
- }
- }
-
- return false;
-}
-
void
IceSSL::Context::parseProtocols(const string& val)
{