Skip to content

Commit

Permalink
OpenSSL support (thanks to Mehmet Bozkurt).
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-richard committed Nov 3, 2012
1 parent cce1c28 commit bc63892
Show file tree
Hide file tree
Showing 39 changed files with 3,557 additions and 963 deletions.
7 changes: 4 additions & 3 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VMIME AUTHOR
============

Vincent Richard <vincent@vincent-richard.net>
Vincent Richard <vincent@vmime.org>
Project owner and creator. VMime was created in 1998, and publicly released
under the GNU GPL license in 2003.

Expand All @@ -28,9 +28,10 @@ AUTHORS file.
- Zarafa <http://developer.zarafa.com/VmimePatches>
- Bartek Szurgot <[email protected], http://baszerr.org>
- Achim Brandt <http://sourceforge.net/users/a-brandt/>
- Mehmet Bozkurt <[email protected]> (OpenSSL support)

Please apologize if I have forgotten someone here. ;) Send me an email
to <vincent@vincent-richard.net> if you want your name to be listed.
to <vincent@vmime.org> if you want your name to be listed.

See SVN Changelog for full list.
See Changelogs for full list.

31 changes: 30 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ ENDIF()
# SSL/TLS support

INCLUDE(FindGnuTLS)
INCLUDE(FindOpenSSL)


INCLUDE(CheckFunctionExists)
Expand All @@ -457,7 +458,7 @@ CHECK_FUNCTION_EXISTS(gnutls_priority_set_direct VMIME_HAVE_GNUTLS_PRIORITY_FUNC

OPTION(
VMIME_HAVE_TLS_SUPPORT
"SSL/TLS support (requires GNU TLS library)"
"SSL/TLS support (requires either GNU TLS or OpenSSL library)"
ON
)

Expand All @@ -467,6 +468,11 @@ OPTION(
ON
)

OPTION(
VMIME_TLS_SUPPORT_LIB_IS_OPENSSL
"Use OpenSSL library for SSL/TLS support"
OFF
)

IF(VMIME_HAVE_TLS_SUPPORT)

Expand All @@ -492,6 +498,23 @@ IF(VMIME_HAVE_TLS_SUPPORT)
SET(VMIME_PKGCONFIG_CFLAGS "${VMIME_PKGCONFIG_CFLAGS} ${GNUTLS_INCLUDE_DIR}")
SET(VMIME_PKGCONFIG_REQUIRES "${VMIME_PKGCONFIG_REQUIRES} libgnutls")

ELSEIF(VMIME_TLS_SUPPORT_LIB_IS_OPENSSL)

INCLUDE_DIRECTORIES(
${INCLUDE_DIRECTORIES}
${OPENSSL_INCLUDE_DIR}
)

TARGET_LINK_LIBRARIES(
${VMIME_LIBRARY_NAME}
${TARGET_LINK_LIBRARIES}
${OPENSSL_LIBRARIES}
)

SET(VMIME_PKGCONFIG_LIBS "${VMIME_PKGCONFIG_LIBS} ${OPENSSL_LIBRARIES}")
SET(VMIME_PKGCONFIG_CFLAGS "${VMIME_PKGCONFIG_CFLAGS} ${OPENSSL_INCLUDE_DIR}")
SET(VMIME_PKGCONFIG_REQUIRES "${VMIME_PKGCONFIG_REQUIRES} libopenssl")

ELSE()

MESSAGE(FATAL_ERROR "TLS support is enabled, but no TLS/SSL library was selected/found")
Expand Down Expand Up @@ -535,8 +558,14 @@ ENDIF()
# POSIX-specific checks

INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)

CHECK_FUNCTION_EXISTS(getaddrinfo VMIME_HAVE_GETADDRINFO)

CHECK_FUNCTION_EXISTS(gettid VMIME_HAVE_GETTID)
CHECK_FUNCTION_EXISTS(syscall VMIME_HAVE_SYSCALL)
CHECK_SYMBOL_EXISTS(SYS_gettid sys/syscall.h VMIME_HAVE_SYSCALL_GETTID)

FIND_PACKAGE(Threads)
FIND_LIBRARY(PTHREAD pthread)

Expand Down
34 changes: 31 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ libvmime_sources = [
'utility/stringUtils.cpp', 'utility/stringUtils.hpp',
'utility/url.cpp', 'utility/url.hpp',
'utility/urlUtils.cpp', 'utility/urlUtils.hpp',
'utility/sync/autoLock.hpp',
'utility/sync/criticalSection.cpp', 'utility/sync/criticalSection.hpp',
# -- encoder
'utility/encoder/encoder.cpp', 'utility/encoder/encoder.hpp',
'utility/encoder/sevenBitEncoder.cpp', 'utility/encoder/sevenBitEncoder.hpp',
Expand Down Expand Up @@ -210,12 +212,19 @@ libvmime_messaging_sources = [
libvmime_net_tls_sources = [
'net/tls/TLSSession.cpp', 'net/tls/TLSSession.hpp',
'net/tls/TLSSocket.cpp', 'net/tls/TLSSocket.hpp',
'net/tls/gnutls/TLSSession_GnuTLS.cpp', 'net/tls/gnutls/TLSSession_GnuTLS.hpp',
'net/tls/gnutls/TLSSocket_GnuTLS.cpp', 'net/tls/gnutls/TLSSocket_GnuTLS.hpp',
'net/tls/openssl/TLSSession_OpenSSL.cpp', 'net/tls/openssl/TLSSession_OpenSSL.hpp',
'net/tls/openssl/TLSSocket_OpenSSL.cpp', 'net/tls/openssl/TLSSocket_OpenSSL.hpp',
'net/tls/openssl/OpenSSLInitializer.cpp', 'net/tls/openssl/OpenSSLInitializer.hpp',
'net/tls/TLSSecuredConnectionInfos.cpp', 'net/tls/TLSSecuredConnectionInfos.hpp',
'security/cert/certificateChain.cpp', 'security/cert/certificateChain.hpp',
'security/cert/certificateVerifier.hpp',
'security/cert/defaultCertificateVerifier.cpp', 'security/cert/defaultCertificateVerifier.hpp',
'security/cert/certificate.hpp',
'security/cert/X509Certificate.cpp', 'security/cert/X509Certificate.hpp'
'security/cert/X509Certificate.cpp', 'security/cert/X509Certificate.hpp',
'security/cert/gnutls/X509Certificate_GnuTLS.cpp', 'security/cert/gnutls/X509Certificate_GnuTLS.hpp',
'security/cert/openssl/X509Certificate_OpenSSL.cpp', 'security/cert/openssl/X509Certificate_OpenSSL.hpp'
]

libvmime_messaging_proto_sources = [
Expand Down Expand Up @@ -282,12 +291,14 @@ libvmime_platforms_sources = {
'posix':
[
'platforms/posix/posixChildProcess.cpp', 'platforms/posix/posixChildProcess.hpp',
'platforms/posix/posixCriticalSection.cpp', 'platforms/posix/posixCriticalSection.hpp',
'platforms/posix/posixFile.cpp', 'platforms/posix/posixFile.hpp',
'platforms/posix/posixHandler.cpp', 'platforms/posix/posixHandler.hpp',
'platforms/posix/posixSocket.cpp', 'platforms/posix/posixSocket.hpp'
],
'windows':
[
'platforms/windows/windowsCriticalSection.cpp', 'platforms/windows/windowsCriticalSection.hpp',
'platforms/windows/windowsFile.cpp', 'platforms/windows/windowsFile.hpp',
'platforms/windows/windowsHandler.cpp', 'platforms/windows/windowsHandler.hpp',
'platforms/windows/windowsSocket.cpp', 'platforms/windows/windowsSocket.hpp'
Expand Down Expand Up @@ -590,6 +601,7 @@ env.Append(CXXFLAGS = ['-Wpointer-arith'])
env.Append(CXXFLAGS = ['-Wold-style-cast'])
env.Append(CXXFLAGS = ['-Wconversion'])
env.Append(CXXFLAGS = ['-Wcast-align'])
env.Append(CXXFLAGS = ['-Wno-long-long']) # OpenSSL
#env.Append(CXXFLAGS = ['-Wshadow'])

env.Append(TARFLAGS = ['-c'])
Expand All @@ -614,6 +626,7 @@ if env['with_sasl'] == 'yes':
env.ParseConfig('pkg-config --cflags --libs ' + libgsasl_pc)

if env['with_tls'] == 'yes':
# GnuTLS
libgnutls_pc = string.strip(os.popen("pkg-config --list-all | grep '^libgnutls[ ]' | cut -f 1 -d ' '").read())

if len(libgnutls_pc) == 0:
Expand All @@ -625,6 +638,15 @@ if env['with_tls'] == 'yes':

env.ParseConfig('pkg-config --cflags --libs ' + libgnutls_pc)

# OpenSSL
libopenssl_pc = string.strip(os.popen("pkg-config --list-all | grep '^openssl[ ]' | cut -f 1 -d ' '").read())

if len(libopenssl_pc) == 0:
print "ERROR: OpenSSL development package is not installed\n"
Exit(1)

env.ParseConfig('pkg-config --cflags --libs ' + libopenssl_pc)

env.Append(CXXFLAGS = ['-pthread'])

# Generate help text for command line options
Expand Down Expand Up @@ -806,6 +828,7 @@ config_hpp.write('// -- TLS/SSL support\n')
if env['with_tls'] == 'yes':
config_hpp.write('#define VMIME_HAVE_TLS_SUPPORT 1\n')
config_hpp.write('#define VMIME_TLS_SUPPORT_LIB_IS_GNUTLS 1\n')
config_hpp.write('#define VMIME_TLS_SUPPORT_LIB_IS_OPENSSL 0\n')
config_hpp.write('#define VMIME_HAVE_GNUTLS_PRIORITY_FUNCS 1\n')
else:
config_hpp.write('#define VMIME_HAVE_TLS_SUPPORT 0\n')
Expand Down Expand Up @@ -834,8 +857,13 @@ for platform in libvmime_platforms_sources:
if not platform in platforms:
config_hpp.write('#define VMIME_PLATFORM_IS_' + string.upper(platform) + ' 0\n')

config_hpp.write('#define VMIME_HAVE_GETADDRINFO 1\n')
config_hpp.write('#define VMIME_HAVE_PTHREAD 1\n')
config_hpp.write("""
#define VMIME_HAVE_GETADDRINFO 1
#define VMIME_HAVE_PTHREAD 1
#define VMIME_HAVE_GETTID 0
#define VMIME_HAVE_SYSCALL 1
#define VMIME_HAVE_SYSCALL_GETTID 1
""")

config_hpp.write('\n')
config_hpp.write('// Miscellaneous flags\n')
Expand Down
4 changes: 4 additions & 0 deletions cmake/config.hpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef unsigned @VMIME_32BIT_TYPE@ vmime_uint32;
// -- TLS/SSL support
#cmakedefine01 VMIME_HAVE_TLS_SUPPORT
#cmakedefine01 VMIME_TLS_SUPPORT_LIB_IS_GNUTLS
#cmakedefine01 VMIME_TLS_SUPPORT_LIB_IS_OPENSSL
#define VMIME_HAVE_GNUTLS_PRIORITY_FUNCS @VMIME_HAVE_GNUTLS_PRIORITY_FUNCS@
// -- Messaging support
#cmakedefine01 VMIME_HAVE_MESSAGING_FEATURES
Expand All @@ -57,6 +58,9 @@ typedef unsigned @VMIME_32BIT_TYPE@ vmime_uint32;
#cmakedefine01 VMIME_PLATFORM_IS_WINDOWS
#cmakedefine01 VMIME_HAVE_PTHREAD
#cmakedefine01 VMIME_HAVE_GETADDRINFO
#cmakedefine01 VMIME_HAVE_GETTID
#cmakedefine01 VMIME_HAVE_SYSCALL
#cmakedefine01 VMIME_HAVE_SYSCALL_GETTID


#define VMIME_SENDMAIL_PATH "@VMIME_SENDMAIL_PATH@"
Expand Down
4 changes: 2 additions & 2 deletions src/net/imap/IMAPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void IMAPConnection::connect()
if (store->isIMAPS()) // dedicated port/IMAPS
{
ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(store->getCertificateVerifier());
tls::TLSSession::create(store->getCertificateVerifier());

ref <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
Expand Down Expand Up @@ -460,7 +460,7 @@ void IMAPConnection::startTLS()
}

ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(m_store.acquire()->getCertificateVerifier());
tls::TLSSession::create(m_store.acquire()->getCertificateVerifier());

ref <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
Expand Down
4 changes: 2 additions & 2 deletions src/net/pop3/POP3Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void POP3Store::connect()
if (m_isPOP3S) // dedicated port/POP3S
{
ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(getCertificateVerifier());
tls::TLSSession::create(getCertificateVerifier());

ref <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
Expand Down Expand Up @@ -550,7 +550,7 @@ void POP3Store::startTLS()
throw exceptions::command_error("STLS", response);

ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(getCertificateVerifier());
tls::TLSSession::create(getCertificateVerifier());

ref <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
Expand Down
4 changes: 2 additions & 2 deletions src/net/smtp/SMTPTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void SMTPTransport::connect()
if (m_isSMTPS) // dedicated port/SMTPS
{
ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(getCertificateVerifier());
tls::TLSSession::create(getCertificateVerifier());

ref <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
Expand Down Expand Up @@ -463,7 +463,7 @@ void SMTPTransport::startTLS()
throw exceptions::command_error("STARTTLS", resp->getText());

ref <tls::TLSSession> tlsSession =
vmime::create <tls::TLSSession>(getCertificateVerifier());
tls::TLSSession::create(getCertificateVerifier());

ref <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
Expand Down
Loading

0 comments on commit bc63892

Please sign in to comment.