Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 84619 Details for
Bug 206875
OpenSSL ssl provider
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Implementation of OpenSSL ssl provider
openssl.txt (text/plain), 24.71 KB, created by
Igor Alelekov
on 2007-12-06 04:31:28 EST
(
hide
)
Description:
Implementation of OpenSSL ssl provider
Filename:
MIME Type:
Creator:
Igor Alelekov
Created:
2007-12-06 04:31:28 EST
Size:
24.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.agentcontroller >Index: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.make >=================================================================== >RCS file: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.make >diff -N src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.make >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.make 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,127 @@ >+ >+################################################################################ >+# >+# makefile: tptpOpenSSL project >+# >+# $Id:$ >+################################################################################ >+ >+ >+#----------------------------------- >+# >+# Customizable section >+# >+# - The TARGETREALNAME variable specifies the name of the library file >+# that will be generated, this includes a base (TARGETLIB) plus a >+# version number plus a minor number plus a release number >+# - The TARGETSONAME variable specifies a file name that has just the >+# library name plus the major version number >+# - The TARGETLIB variable specifies the base library name >+# - The TARGETSONAME and TARGETLIB are generated as symbolic links >+# when the library is built >+# >+#----------------------------------- >+TARGET := libtptpOpenSSL >+TARGETDIR := ../../../lib >+ >+if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi >+if [ x$MINORNUM = x ]; then export MINORNUM=0; fi >+if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi >+ >+TARGETLIB := $(TARGET).so >+TARGETSONAME := $(TARGETLIB).$(VERSIONNUM) >+TARGETREALNAME := $(TARGETSONAME).$(MINORNUM).$(RELEASENUM) >+ >+ >+#----------------------------------- >+# list of additional INCLUDE directories to search headers from >+# (separated by blanks) >+#----------------------------------- >+INCLUDEDIRS := . ../../../include >+ >+ >+#----------------------------------- >+# list of additional libraries to be linked with >+# (separated by blanks) >+#----------------------------------- >+LIBS := dl transportSupport >+ >+#----------------------------------- >+# list of additional library directories to search from >+# (separated by blanks) >+#----------------------------------- >+LIBDIRS := ../../../lib >+ >+ >+#----------------------------------- >+# >+# Compiler options >+# >+# -g produce debug info >+# -Wall enable all types of warnings >+# -O3 highest level of code optimization >+# -fPIC generate position-independent code (PIC). >+# This is required for building shared library. >+# -c compile only >+# >+# Linking options >+# >+# -Wl pass options to linker >+# -shared produce shared library >+# -L add the given directory to the search path for libraries >+# >+#----------------------------------- >+ >+CFLAGS := $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS)) -D_LINUX_X86 >+ >+CXXFLAGS := $(CFLAGS) >+ >+LINKOPTS := $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS)) >+ >+ >+#----------------------------------- >+# general commands and options >+#----------------------------------- >+ >+CC := gcc >+CXX := $(CC) >+ >+SOURCE := $(wildcard *.c) $(wildcard *.cpp) >+ >+OBJS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE))) >+ >+REMOVEFILE := rm -f >+CREATELINK := ln -sf >+ >+ >+#----------------------------------- >+# "make" rules >+#----------------------------------- >+ >+.PHONY : default everything objs clean veryclean rebuild $(TARGET) >+ >+ >+default : $(TARGET) >+ >+ >+objs : $(OBJS) >+ >+ >+clean : >+ $(REMOVEFILE) *.o >+ >+ >+veryclean: clean >+ $(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB) >+ $(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME) >+ $(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME) >+ >+ >+rebuild: veryclean everything >+ >+ >+$(TARGET) : $(OBJS) >+ $(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS)) >+ $(CREATELINK) $(TARGETREALNAME) $(TARGETDIR)/$(TARGETSONAME) >+ $(CREATELINK) $(TARGETSONAME) $(TARGETDIR)/$(TARGETLIB) >+ >Index: src-native-new/src/transport/tptpOpenSSL/openSSLLog.h >=================================================================== >RCS file: src-native-new/src/transport/tptpOpenSSL/openSSLLog.h >diff -N src-native-new/src/transport/tptpOpenSSL/openSSLLog.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/transport/tptpOpenSSL/openSSLLog.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 Intel Corporation. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Igor Alelekov, Intel - Initial implementation >+ * >+ * $Id$ >+ * >+ *******************************************************************************/ >+ >+#ifndef _OPENSSLLOG_H_ >+#define _OPENSSLLOG_H_ >+ >+/***************************************************************************************************** >+ * * >+ * To use the log macros in TPTPLog.h, the following must be defined: * >+ * * >+ * RESOLVE_LOG_EVENT_FUNC(p) resolves to a logEvent function pointer * >+ * RESOLVE_INITIAL_PARAM(p) if a parameter is needed before the subcomponent, this macro * >+ * should give that parameter, including the separating comma * >+ * if no such parameter is needed this macro should resolve to * >+ * white space * >+ * TPTP_LOG_SUBCOMPONENT_NAME(p) the name of the subcomponent to appear in the log file * >+ * TPTP_LOG_INSTANCE_ID(p) an instance ID for the log file * >+ * * >+ *****************************************************************************************************/ >+ >+/* These definitions assume 'p' will point to a server_block_t as defined in SocketListener.h */ >+ >+#define RESOLVE_LOG_EVENT_FUNC(p) p->logEventEntry >+#define RESOLVE_INITIAL_PARAM(p) p->cmo, /* Note: this trailing comma is required */ >+#define TPTP_LOG_SUBCOMPONENT_NAME(p) "tptpOpenSSL" >+#define TPTP_LOG_INSTANCE_ID(p) 0 >+ >+/* Do not move this include, it requires the above definitions */ >+#include "tptp/TPTPLog.h" >+ >+#endif /* _OPENSSLLOG_H_ */ >Index: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.dsp >=================================================================== >RCS file: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.dsp >diff -N src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.dsp >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.dsp 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,125 @@ >+# Microsoft Developer Studio Project File - Name="tptpOpenSSL" - Package Owner=<4> >+# Microsoft Developer Studio Generated Build File, Format Version 6.00 >+# ** DO NOT EDIT ** >+ >+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 >+ >+CFG=tptpOpenSSL - Win32 Debug >+!MESSAGE This is not a valid makefile. To build this project using NMAKE, >+!MESSAGE use the Export Makefile command and run >+!MESSAGE >+!MESSAGE NMAKE /f "tptpOpenSSL.mak". >+!MESSAGE >+!MESSAGE You can specify a configuration when running NMAKE >+!MESSAGE by defining the macro CFG on the command line. For example: >+!MESSAGE >+!MESSAGE NMAKE /f "tptpOpenSSL.mak" CFG="tptpOpenSSL - Win32 Debug" >+!MESSAGE >+!MESSAGE Possible choices for configuration are: >+!MESSAGE >+!MESSAGE "tptpOpenSSL - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE "tptpOpenSSL - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") >+!MESSAGE >+ >+# Begin Project >+# PROP AllowPerConfigDependencies 0 >+# PROP Scc_ProjName "" >+# PROP Scc_LocalPath "" >+CPP=cl.exe >+MTL=midl.exe >+RSC=rc.exe >+ >+!IF "$(CFG)" == "tptpOpenSSL - Win32 Release" >+ >+# PROP BASE Use_MFC 0 >+# PROP BASE Use_Debug_Libraries 0 >+# PROP BASE Output_Dir "Release" >+# PROP BASE Intermediate_Dir "Release" >+# PROP BASE Target_Dir "" >+# PROP Use_MFC 0 >+# PROP Use_Debug_Libraries 0 >+# PROP Output_Dir "../../../bin" >+# PROP Intermediate_Dir "Release" >+# PROP Ignore_Export_Lib 0 >+# PROP Target_Dir "" >+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPOPENSSL_EXPORTS" /YX /FD /c >+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPOPENSSL_EXPORTS" /YX /FD /I $(OPENSSL_HOME)/include /c >+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 >+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 >+# ADD BASE RSC /l 0x419 /d "NDEBUG" >+# ADD RSC /l 0x419 /d "NDEBUG" >+BSC32=bscmake.exe >+# ADD BASE BSC32 /nologo >+# ADD BSC32 /nologo >+LINK32=link.exe >+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 >+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib transportSupport.lib /nologo /dll /machine:I386 /libpath:"../../../lib" >+# SUBTRACT LINK32 /pdb:none >+ >+!ELSEIF "$(CFG)" == "tptpOpenSSL - Win32 Debug" >+ >+# PROP BASE Use_MFC 0 >+# PROP BASE Use_Debug_Libraries 1 >+# PROP BASE Output_Dir "Debug" >+# PROP BASE Intermediate_Dir "Debug" >+# PROP BASE Target_Dir "" >+# PROP Use_MFC 0 >+# PROP Use_Debug_Libraries 1 >+# PROP Output_Dir "../../../bin" >+# PROP Intermediate_Dir "Debug" >+# PROP Ignore_Export_Lib 0 >+# PROP Target_Dir "" >+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPOPENSSL_EXPORTS" /YX /FD /GZ /c >+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPOPENSSL_EXPORTS" /YX /FD /GZ /I $(OPENSSL_HOME)/include /c >+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 >+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 >+# ADD BASE RSC /l 0x419 /d "_DEBUG" >+# ADD RSC /l 0x419 /d "_DEBUG" >+BSC32=bscmake.exe >+# ADD BASE BSC32 /nologo >+# ADD BSC32 /nologo >+LINK32=link.exe >+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept >+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib transportSupport.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"../../../lib" >+# SUBTRACT LINK32 /pdb:none >+ >+!ENDIF >+ >+# Begin Target >+ >+# Name "tptpOpenSSL - Win32 Release" >+# Name "tptpOpenSSL - Win32 Debug" >+# Begin Group "Source Files" >+ >+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" >+# Begin Source File >+ >+SOURCE=.\tptpOpenSSL.c >+# End Source File >+# Begin Source File >+ >+SOURCE=.\tptpOpenSSL.def >+# End Source File >+# End Group >+# Begin Group "Header Files" >+ >+# PROP Default_Filter "h;hpp;hxx;hm;inl" >+# Begin Source File >+ >+SOURCE=.\openSSLLog.h >+# End Source File >+# Begin Source File >+ >+SOURCE=.\openSSLTypes.h >+# End Source File >+# Begin Source File >+ >+SOURCE=.\tptpOpenSSL.h >+# End Source File >+# End Group >+# Begin Group "Resource Files" >+ >+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" >+# End Group >+# End Target >+# End Project >Index: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.c >=================================================================== >RCS file: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.c >diff -N src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.c 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,339 @@ >+#include <stdio.h> >+#include <stdlib.h> >+#include <string.h> >+#include <errno.h> >+ >+#ifdef _WIN32 >+ #include <direct.h> >+#else >+ #include <unistd.h> >+#endif >+ >+#include "tptpOpenSSL.h" >+#include "openSSLTypes.h" >+#include "tptp/tptpSSLProvider.h" >+#include "openSSLLog.h" >+ >+/* Resolved OpenSSL functions */ >+static sslv23_server_method_t sslv23_server_method; >+static ssl_CTX_new_t ssl_CTX_new; >+static ssl_CTX_use_certificate_file_t ssl_CTX_use_certificate_file; >+static ssl_CTX_use_PrivateKey_file_t ssl_CTX_use_PrivateKey_file; >+static ssl_CTX_check_private_key_t ssl_CTX_check_private_key; >+static ssl_new_t ssl_new; >+static ssl_set_fd_t ssl_set_fd; >+static ssl_accept_t ssl_accept; >+static ssl_read_t ssl_read; >+static ssl_write_t ssl_write; >+static ssl_get_error_t ssl_get_error; >+static ssl_free_t ssl_free; >+static ssl_CTX_free_t ssl_CTX_free; >+static ssl_shutdown_t ssl_shutdown; >+ >+static SOCKET serverSocket; >+static char* certFile = NULL; >+static char* keyFile = NULL; >+ >+static log_service_t *logService; >+ >+static int initKeys(); >+static int loadOpenSSLLibrary(); >+ >+int sslInit(log_service_t *_logService, int port) { >+ struct sockaddr_in saddr; >+ int rc; >+ >+ logService = _logService; >+ >+ if (loadOpenSSLLibrary() < 0) { >+ TPTP_LOG_ERROR_MSG(logService, "Error: unable to load tptpSSLProvider's openssl library.") ; >+ return -1; >+ } >+ >+ if (initKeys() < 0) { >+ return -1; >+ } >+ >+ /* create and initialize the server socket */ >+ serverSocket = getTheSocket(port, &saddr); >+ >+ if (serverSocket < 0) { >+ TPTP_LOG_ERROR_MSG1(logService, "Error: unable to create the server socket at port %d.", port) ; >+ return -1; >+ } >+ else { >+ rc = bindAndListen(serverSocket, (struct sockaddr*)&saddr) ; >+ } >+ >+ TPTP_LOG_DEBUG_MSG1(logService, "Socket server is running at port number of %d.", port) ; >+ >+ return rc; >+} >+ >+void* sslAccept() { >+ ssl_socket_t ssl_socket; >+ SOCKET clientSocket; >+ >+ clientSocket = acceptSocketConnection(serverSocket); >+ if (isSocketValid(clientSocket) == 0) { >+ TPTP_LOG_ERROR_MSG(logService, "Accept() receives invalid socket request.") ; >+ return NULL; >+ } >+ >+ setHandleInherited((HANDLE) clientSocket); >+ >+ /* set up the data block for each request */ >+ ssl_socket = (ssl_socket_t) malloc(sizeof(ssl_socket_data_t)); >+ ssl_socket->clientSocket = clientSocket; >+ ssl_socket->secured = FALSE; >+ >+ return ssl_socket; >+} >+ >+int sslHandshake(void* _ssl_socket) { >+ ssl_socket_t ssl_socket = (ssl_socket_t) _ssl_socket; // to make compiler happy :) >+ SSL_METHOD *meth; >+ SSL_CTX* ctx; >+ SSL* ssl; >+ int err; >+ >+ meth = (*sslv23_server_method)(); >+ >+ ctx = (*ssl_CTX_new)(meth); >+ if (!ctx) { >+ TPTP_LOG_DEBUG_MSG(logService, "SSL: context error"); >+ return -1; >+ } >+ >+ if (certFile == NULL) { >+ TPTP_LOG_DEBUG_MSG(logService, "SSL: no certificate file found"); >+ return -1; >+ } >+ >+ if ((*ssl_CTX_use_certificate_file)(ctx, certFile, SSL_FILETYPE_PEM) <= 0) { >+ TPTP_LOG_DEBUG_MSG1(logService, "SSL: invalid certificate file %s", certFile); >+ return -1; >+ } >+ >+ if (keyFile == NULL) { >+ TPTP_LOG_DEBUG_MSG(logService, "SSL: no key file found"); >+ return -1; >+ } >+ >+ if ((*ssl_CTX_use_PrivateKey_file)(ctx, keyFile, SSL_FILETYPE_PEM) <= 0) { >+ TPTP_LOG_DEBUG_MSG1(logService, "SSL: invalid key file %s", keyFile); >+ return -1; >+ } >+ >+ if (!(*ssl_CTX_check_private_key)(ctx)) { >+ TPTP_LOG_DEBUG_MSG2(logService, "SSL: Private key %s does not match the certificate public key %s", >+ keyFile, certFile); >+ return -1; >+ } >+ >+ ssl = (*ssl_new)(ctx); >+ if (ssl < 0) { >+ TPTP_LOG_DEBUG_MSG(logService, "SSL.new error"); >+ return -1; >+ } >+ >+ (*ssl_set_fd)(ssl, ssl_socket->clientSocket); >+ err = (*ssl_accept)(ssl); >+ if (err < 0) { >+ TPTP_LOG_DEBUG_MSG1(logService, "SSL: ssl_accept error %d", (*ssl_get_error)(ssl, err)); >+ return -1; >+ } >+ >+ ssl_socket->secured = TRUE; >+ ssl_socket->sslCtx = ctx; >+ ssl_socket->ssl = ssl; >+ >+ return 0; >+} >+ >+int sslRead(void* _ssl_socket, char* buffer, int length) { >+ ssl_socket_t ssl_socket = (ssl_socket_t) _ssl_socket; >+ int rc, bytesRead; >+ >+ if (ssl_socket == NULL) return -1; >+ >+ if (ssl_socket->secured) { >+ return (ssl_read == NULL) ? -1 : (*ssl_read)(ssl_socket->ssl, buffer, length); >+ } >+ else { >+ rc = readFromSocket(ssl_socket->clientSocket, buffer, length, &bytesRead); >+ return (rc < 0) ? -1 : bytesRead; >+ } >+} >+ >+int sslWrite(void* _ssl_socket, char* buffer, int length) { >+ ssl_socket_t ssl_socket = (ssl_socket_t) _ssl_socket; >+ if (ssl_socket == NULL) return -1; >+ >+ if (ssl_socket->secured) { >+ return (ssl_write == NULL) ? -1 : (*ssl_write)(ssl_socket->ssl, buffer, length); >+ } >+ else { >+ return writeToSocket(ssl_socket->clientSocket, buffer, length); >+ } >+} >+ >+int sslClose(void* _ssl_socket) { >+ ssl_socket_t ssl_socket = (ssl_socket_t) _ssl_socket; >+ if (ssl_socket == NULL) return -1; >+ >+ if (ssl_socket->ssl != NULL) { >+ (*ssl_shutdown)(ssl_socket->ssl); >+ } >+ >+ closeSocket(ssl_socket->clientSocket); >+ >+ if (ssl_socket->ssl != NULL) { >+ (*ssl_free)(ssl_socket->ssl); >+ ssl_socket->ssl = NULL; >+ } >+ >+ if (ssl_socket->sslCtx != NULL) { >+ (*ssl_CTX_free)(ssl_socket->sslCtx); >+ ssl_socket->sslCtx = NULL; >+ } >+ >+ free(ssl_socket); >+ >+ return 0; >+} >+ >+int sslReset() { >+ closeSocket(serverSocket); >+ return 0; >+} >+ >+int loadOpenSSLLibrary() { >+ DLL_REFERENCE opensslLibrary; >+ ssl_load_error_strings_t ssl_load_error_strings = NULL; >+ ssl_library_init_t ssl_library_init = NULL; >+ int rc; >+ >+ opensslLibrary = LOAD_LIBRARY(SSL_LIBRARY_NAME); >+ if (opensslLibrary == NULL) { >+ TPTP_LOG_ERROR_MSG(logService, "Unable to find openssl library") ; >+ return -1; >+ } >+ >+ ssl_load_error_strings = (ssl_load_error_strings_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_LOAD_ESTRINGS); >+ ssl_library_init = (ssl_library_init_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_LIBRARY_INIT); >+ sslv23_server_method = (sslv23_server_method_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSLV23_SERVER_METHOD); >+ ssl_CTX_new = (ssl_CTX_new_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_CTX_NEW); >+ ssl_CTX_use_certificate_file = (ssl_CTX_use_certificate_file_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_CTX_CERT_FILE); >+ ssl_CTX_use_PrivateKey_file = (ssl_CTX_use_PrivateKey_file_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_CTX_KEY_FILE); >+ ssl_CTX_check_private_key = (ssl_CTX_check_private_key_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_CTX_CHECK_KEY); >+ ssl_new = (ssl_new_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_NEW); >+ ssl_set_fd = (ssl_set_fd_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_SET_FD); >+ ssl_accept = (ssl_accept_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_ACCEPT); >+ ssl_read = (ssl_read_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_READ); >+ ssl_write = (ssl_write_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_WRITE); >+ ssl_get_error = (ssl_get_error_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_GET_ERROR); >+ ssl_free = (ssl_free_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_FREE); >+ ssl_CTX_free = (ssl_CTX_free_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_CTX_FREE); >+ ssl_shutdown = (ssl_shutdown_t) RESOLVE_ENTRY_POINT(opensslLibrary, SSL_SHUTDOWN); >+ >+ /* Check to make sure we found everything */ >+ if (ssl_load_error_strings && >+ ssl_library_init && >+ sslv23_server_method && >+ ssl_CTX_new && >+ ssl_CTX_use_certificate_file && >+ ssl_CTX_use_PrivateKey_file && >+ ssl_CTX_check_private_key && >+ ssl_new && >+ ssl_set_fd && >+ ssl_accept && >+ ssl_read && >+ ssl_write && >+ ssl_get_error && >+ ssl_free && >+ ssl_shutdown && >+ ssl_CTX_free) { >+ >+ (*ssl_load_error_strings)(); >+ (*ssl_library_init)(); >+ >+ rc = 0; >+ } >+ else { >+ TPTP_LOG_ERROR_MSG(logService, "Unable to resolve openssl library"); >+ rc = -1; >+ } >+ >+ return rc; >+} >+ >+int checkFile (char* fileName) { >+ FILE *fp; >+ >+ if (fileName == NULL) return -1; >+ >+ fp = fopen(fileName, "r"); >+ if (fp == NULL) { >+ return -1; >+ } >+ >+ fclose(fp); >+ >+ return 0; >+} >+ >+int initKeys() { >+ if (certFile == NULL) { >+ TPTP_LOG_ERROR_MSG(logService, "SSL: no certificate file provided"); >+ return -1; >+ } >+ >+ if (checkFile(certFile) < 0) { >+ TPTP_LOG_ERROR_MSG1(logService, "SSL: certificate file %s not found", certFile); >+ return -1; >+ } >+ >+ if (keyFile == NULL) { >+ TPTP_LOG_ERROR_MSG(logService, "SSL: no key file provided"); >+ return -1; >+ } >+ >+ if (checkFile(keyFile) < 0) { >+ TPTP_LOG_ERROR_MSG1(logService, "SSL: key file %s not found\n", keyFile); >+ return -1; >+ } >+ >+ return 0; >+} >+ >+void sslSetValue(const char* name, const char* value) { >+ if (!strcmp(CERTIFICATE_FILE_KEY,name)) { >+ if (value == NULL) >+ certFile = NULL; >+ else { >+ if (certFile != NULL) free(certFile); >+ certFile = (char*) malloc(strlen(value)+1); >+ strcpy(certFile, value); >+ } >+ } >+ else if (!strcmp(KEYS_FILE_KEY,name)) { >+ if (value == NULL) >+ keyFile = NULL; >+ else { >+ if (keyFile != NULL) free(keyFile); >+ keyFile = (char*) malloc(strlen(value)+1); >+ strcpy(keyFile, value); >+ } >+ } >+} >+ >+char* sslGetValue(const char* name) { >+ if (!strcmp(CERTIFICATE_FILE_KEY,name)) return certFile; >+ if (!strcmp(KEYS_FILE_KEY,name)) return keyFile; >+ return NULL; >+} >+ >+char* sslGetProviderName() { >+ return VERSION_NUMBER; >+} >Index: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.h >=================================================================== >RCS file: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.h >diff -N src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,17 @@ >+#ifndef TPTP_OPENSSL_H >+#define TPTP_OPENSSL_H >+ >+#include <openssl/ssl.h> >+#include "tptp/SocketTL.h" >+#include "tptp/TransportSupport.h" >+ >+typedef struct { >+ BOOL secured; >+ SOCKET clientSocket; >+ SSL_CTX* sslCtx; >+ SSL* ssl; >+} ssl_socket_data_t; >+ >+typedef ssl_socket_data_t* ssl_socket_t; >+ >+#endif >Index: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.def >=================================================================== >RCS file: src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.def >diff -N src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.def >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/transport/tptpOpenSSL/tptpOpenSSL.def 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,13 @@ >+LIBRARY tptpOpenSSL >+DESCRIPTION "OpenSSL ssl provider." >+EXPORTS >+ sslInit >+ sslAccept >+ sslHandshake >+ sslRead >+ sslWrite >+ sslClose >+ sslReset >+ sslGetValue >+ sslSetValue >+ sslGetProviderName >Index: src-native-new/src/transport/tptpOpenSSL/openSSLTypes.h >=================================================================== >RCS file: src-native-new/src/transport/tptpOpenSSL/openSSLTypes.h >diff -N src-native-new/src/transport/tptpOpenSSL/openSSLTypes.h >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-native-new/src/transport/tptpOpenSSL/openSSLTypes.h 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+#ifndef _OPENSSL_TYPES_H >+#define _OPENSSL_TYPES_H >+ >+#include <openssl/ssl.h> >+ >+#define VERSION_NUMBER "tptpOpenSSL provider v.1.0" >+#define CERTIFICATE_FILE_KEY "certificate.file" >+#define KEYS_FILE_KEY "keys.file" >+ >+#ifdef _WIN32 >+ #define SSL_LIBRARY_NAME "libssl32" >+#else >+ #define SSL_LIBRARY_NAME "libssl.so" >+#endif >+ >+/* OpenSSL function names to be imported */ >+#define SSL_LOAD_ESTRINGS "SSL_load_error_strings" >+#define SSL_LIBRARY_INIT "SSL_library_init" >+#define SSLV23_SERVER_METHOD "SSLv23_server_method" >+#define SSL_CTX_NEW "SSL_CTX_new" >+#define SSL_CTX_CERT_FILE "SSL_CTX_use_certificate_file" >+#define SSL_CTX_KEY_FILE "SSL_CTX_use_PrivateKey_file" >+#define SSL_CTX_CHECK_KEY "SSL_CTX_check_private_key" >+#define SSL_NEW "SSL_new" >+#define SSL_SET_FD "SSL_set_fd" >+#define SSL_ACCEPT "SSL_accept" >+#define SSL_READ "SSL_read" >+#define SSL_WRITE "SSL_write" >+#define SSL_GET_ERROR "SSL_get_error" >+#define SSL_FREE "SSL_free" >+#define SSL_CTX_FREE "SSL_CTX_free" >+#define SSL_SHUTDOWN "SSL_shutdown" >+ >+/* OpenSSL function types */ >+typedef void (*ssl_load_error_strings_t)(); >+typedef void (*ssl_library_init_t)(); >+typedef SSL_METHOD* (*sslv23_server_method_t)(); >+typedef SSL_CTX* (*ssl_CTX_new_t)(); >+typedef int (*ssl_CTX_use_certificate_file_t)(); >+typedef int (*ssl_CTX_use_PrivateKey_file_t)(); >+typedef int (*ssl_CTX_check_private_key_t)(); >+typedef SSL* (*ssl_new_t)(); >+typedef int (*ssl_set_fd_t)(); >+typedef int (*ssl_accept_t)(); >+typedef int (*ssl_read_t)(); >+typedef int (*ssl_write_t)(); >+typedef int (*ssl_get_error_t)(); >+typedef char* (*ssl_free_t)(); >+typedef char* (*ssl_CTX_free_t)(); >+typedef int (*ssl_shutdown_t)(); >+ >+#endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 206875
: 84619