|
@@ -71,13 +71,28 @@ bool accept_selfsigned = false;
|
|
|
throw MakeStringException(-1, "SecureSocket Exception Raised in: %s, line %d - %s", __FILE__, __LINE__, err);
|
|
|
|
|
|
|
|
|
-int pem_passwd_cb(char* buf, int size, int rwflag, void* password)
|
|
|
+static int pem_passwd_cb(char* buf, int size, int rwflag, void* password)
|
|
|
{
|
|
|
strncpy(buf, (char*)password, size);
|
|
|
buf[size - 1] = '\0';
|
|
|
return(strlen(buf));
|
|
|
}
|
|
|
|
|
|
+static void readBio(BIO* bio, StringBuffer& buf)
|
|
|
+{
|
|
|
+ char readbuf[1024];
|
|
|
+
|
|
|
+ int len = 0;
|
|
|
+ while((len = BIO_read(bio, readbuf, 1024)) > 0)
|
|
|
+ {
|
|
|
+ buf.append(len, readbuf);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//Use a namespace to prevent clashes with a class of the same name in jhtree
|
|
|
+namespace securesocket
|
|
|
+{
|
|
|
+
|
|
|
class CStringSet : public CInterface, implements IInterface
|
|
|
{
|
|
|
class StringHolder : public CInterface
|
|
@@ -112,7 +127,6 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
class CSecureSocket : public CInterface, implements ISecureSocket
|
|
|
{
|
|
|
private:
|
|
@@ -1015,17 +1029,6 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-void readBio(BIO* bio, StringBuffer& buf)
|
|
|
-{
|
|
|
- char readbuf[1024];
|
|
|
-
|
|
|
- int len = 0;
|
|
|
- while((len = BIO_read(bio, readbuf, 1024)) > 0)
|
|
|
- {
|
|
|
- buf.append(len, readbuf);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
class CRsaCertificate : public CInterface, implements ICertificate
|
|
|
{
|
|
|
private:
|
|
@@ -1464,6 +1467,8 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
extern "C" {
|
|
|
CriticalSection factoryCrit;
|
|
|
|
|
@@ -1472,12 +1477,12 @@ SECURESOCKET_API ISecureSocketContext* createSecureSocketContext(SecureSocketTyp
|
|
|
CriticalBlock b(factoryCrit);
|
|
|
if(sockettype == ClientSocket)
|
|
|
{
|
|
|
- return new CSecureSocketContext(sockettype);
|
|
|
+ return new securesocket::CSecureSocketContext(sockettype);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(server_securesocket_context.get() == NULL)
|
|
|
- server_securesocket_context.setown(new CSecureSocketContext(sockettype));
|
|
|
+ server_securesocket_context.setown(new securesocket::CSecureSocketContext(sockettype));
|
|
|
return server_securesocket_context.getLink();
|
|
|
}
|
|
|
}
|
|
@@ -1487,12 +1492,12 @@ SECURESOCKET_API ISecureSocketContext* createSecureSocketContextEx(const char* c
|
|
|
CriticalBlock b(factoryCrit);
|
|
|
if(sockettype == ClientSocket)
|
|
|
{
|
|
|
- return new CSecureSocketContext(certfile, privkeyfile, passphrase, sockettype);
|
|
|
+ return new securesocket::CSecureSocketContext(certfile, privkeyfile, passphrase, sockettype);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(server_securesocket_context.get() == NULL)
|
|
|
- server_securesocket_context.setown(new CSecureSocketContext(certfile, privkeyfile, passphrase, sockettype));
|
|
|
+ server_securesocket_context.setown(new securesocket::CSecureSocketContext(certfile, privkeyfile, passphrase, sockettype));
|
|
|
return server_securesocket_context.getLink();
|
|
|
}
|
|
|
}
|
|
@@ -1505,19 +1510,19 @@ SECURESOCKET_API ISecureSocketContext* createSecureSocketContextEx2(IPropertyTre
|
|
|
CriticalBlock b(factoryCrit);
|
|
|
if(sockettype == ClientSocket)
|
|
|
{
|
|
|
- return new CSecureSocketContext(config, sockettype);
|
|
|
+ return new securesocket::CSecureSocketContext(config, sockettype);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(server_securesocket_context.get() == NULL)
|
|
|
- server_securesocket_context.setown(new CSecureSocketContext(config, sockettype));
|
|
|
+ server_securesocket_context.setown(new securesocket::CSecureSocketContext(config, sockettype));
|
|
|
return server_securesocket_context.getLink();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
SECURESOCKET_API ICertificate *createCertificate()
|
|
|
{
|
|
|
- return new CRsaCertificate();
|
|
|
+ return new securesocket::CRsaCertificate();
|
|
|
}
|
|
|
|
|
|
SECURESOCKET_API int signCertificate(const char* csr, const char* ca_certificate, const char* ca_privkey, const char* ca_passphrase, int days, StringBuffer& certificate)
|