From 0c9e9262fa52af648770ba48a9b6ac032447cefe Mon Sep 17 00:00:00 2001 From: Marco Bambini Date: Thu, 28 Dec 2023 14:05:41 +0100 Subject: [PATCH] Updated internal test --- .gitignore | 1 + .../OpenSSL.xcodeproj/project.pbxproj | 22 +++++++---- Internals/{OpenSSL => TestTLS}/OpenSSL/main.c | 38 +++++++++++++------ 3 files changed, 41 insertions(+), 20 deletions(-) rename Internals/{OpenSSL => TestTLS}/OpenSSL.xcodeproj/project.pbxproj (94%) rename Internals/{OpenSSL => TestTLS}/OpenSSL/main.c (80%) diff --git a/.gitignore b/.gitignore index b148ab8..48d97d9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ Internals/old/ .DS_Store Sample/MacOS/Client/cubeSQLTest.xcodeproj/project.pbxproj Sample/Console/XCode/testapp.xcodeproj/xcshareddata/xcschemes/testapp.xcscheme +Internals/TestTLS/OpenSSL.xcodeproj/xcshareddata/xcschemes/OpenSSL.xcscheme diff --git a/Internals/OpenSSL/OpenSSL.xcodeproj/project.pbxproj b/Internals/TestTLS/OpenSSL.xcodeproj/project.pbxproj similarity index 94% rename from Internals/OpenSSL/OpenSSL.xcodeproj/project.pbxproj rename to Internals/TestTLS/OpenSSL.xcodeproj/project.pbxproj index 0866452..bf6a976 100644 --- a/Internals/OpenSSL/OpenSSL.xcodeproj/project.pbxproj +++ b/Internals/TestTLS/OpenSSL.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ A9DB49D62209C94200C0E3F1 /* pseudorandom.c in Sources */ = {isa = PBXBuildFile; fileRef = A9DB49B32209C5C500C0E3F1 /* pseudorandom.c */; }; A9DB49D72209C94400C0E3F1 /* base64.c in Sources */ = {isa = PBXBuildFile; fileRef = A9DB49B52209C5C500C0E3F1 /* base64.c */; }; A9DB49D82209C94700C0E3F1 /* aestab.c in Sources */ = {isa = PBXBuildFile; fileRef = A9DB49B62209C5C500C0E3F1 /* aestab.c */; }; + A9DFF2F82B3DA8FC00CAD971 /* libtls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A9DFF2F72B3DA8FC00CAD971 /* libtls.a */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -47,6 +48,7 @@ A9DB49B72209C5C500C0E3F1 /* sha1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sha1.h; sourceTree = ""; }; A9DB49B82209C5C500C0E3F1 /* csql.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = csql.h; sourceTree = ""; }; A9DB49BE2209C5C500C0E3F1 /* cubesql.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cubesql.h; sourceTree = ""; }; + A9DFF2F72B3DA8FC00CAD971 /* libtls.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtls.a; path = ../libs/macOS/libtls.a; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,6 +56,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + A9DFF2F82B3DA8FC00CAD971 /* libtls.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -79,8 +82,8 @@ A9DB49A12209C59200C0E3F1 /* OpenSSL */ = { isa = PBXGroup; children = ( - A9DB49A92209C5C500C0E3F1 /* C_SDK */, A9DB49A22209C59200C0E3F1 /* main.c */, + A9DB49A92209C5C500C0E3F1 /* C_SDK */, ); path = OpenSSL; sourceTree = ""; @@ -88,6 +91,7 @@ A9DB49A92209C5C500C0E3F1 /* C_SDK */ = { isa = PBXGroup; children = ( + A9DFF2F72B3DA8FC00CAD971 /* libtls.a */, A9DB49AA2209C5C500C0E3F1 /* cubesql.c */, A9DB49BE2209C5C500C0E3F1 /* cubesql.h */, A9DB49B82209C5C500C0E3F1 /* csql.h */, @@ -305,11 +309,13 @@ DEVELOPMENT_TEAM = 3ZH6236ET5; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", - "CUBESQL_ENABLE_SSL_ENCRYPTION=1", - "CUBESQL_DYNAMIC_SSL_LIBRARY=1", "$(inherited)", ); - HEADER_SEARCH_PATHS = "/Users/marco/GitHub/SQLabs/sdk/C_SDK/**"; + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../C_SDK/crypt\"", + "\"$(SRCROOT)/../../C_SDK\"", + ); + LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../libs/macOS\""; OTHER_LDFLAGS = "-lz"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -320,11 +326,11 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 3ZH6236ET5; - GCC_PREPROCESSOR_DEFINITIONS = ( - "CUBESQL_ENABLE_SSL_ENCRYPTION=1", - "CUBESQL_DYNAMIC_SSL_LIBRARY=1", + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../C_SDK/crypt\"", + "\"$(SRCROOT)/../../C_SDK\"", ); - HEADER_SEARCH_PATHS = "/Users/marco/GitHub/SQLabs/sdk/C_SDK/**"; + LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../libs/macOS\""; OTHER_LDFLAGS = "-lz"; PRODUCT_NAME = "$(TARGET_NAME)"; }; diff --git a/Internals/OpenSSL/OpenSSL/main.c b/Internals/TestTLS/OpenSSL/main.c similarity index 80% rename from Internals/OpenSSL/OpenSSL/main.c rename to Internals/TestTLS/OpenSSL/main.c index b1f43b1..0de5527 100644 --- a/Internals/OpenSSL/OpenSSL/main.c +++ b/Internals/TestTLS/OpenSSL/main.c @@ -97,26 +97,32 @@ void print_cursor(csqlc *c) { printf("\n"); } -int main(int argc, const char * argv[]) { +int do_test_clear (void) { csqldb *db = NULL; - // "/Users/marco/Desktop/OpenSSL_1_macOS/libcrypto.1.0.0.dylib" - // "/Users/marco/Desktop/OpenSSL_1_macOS/libssl.1.0.0.dylib" - // "/Users/marco/Desktop/SQLabs/openssl/pluginissue_cert_win-64bit/Hosting.crt" + if (cubesql_connect(&db, HOSTNAME, CUBESQL_DEFAULT_PORT, USERNAME, PASSWORD, CUBESQL_DEFAULT_TIMEOUT, CUBESQL_ENCRYPTION_NONE) != CUBESQL_NOERR) goto abort; - // path to OpenSSL 1.1 libraries -// cubesql_setpath(CUBESQL_CRYPTO_LIBRARY_PATH, "/Users/marco/Desktop/SQLabs/openssl/libcrypto.1.1.dylib"); -// cubesql_setpath(CUBESQL_SSL_LIBRARY_PATH, "/Users/marco/Desktop/SQLabs/openssl/libssl.1.1.dylib"); - const char *certificatePath = NULL;// "/Users/marco/Desktop/SQLabs/openssl/pluginissue_cert_win-64bit/Hosting.crt"; + do_test(db); - do_print_ssl(); + // disconnect + cubesql_disconnect(db, kTRUE); + return 0; - // connection with SSL encryption - if (cubesql_connect_ssl(&db, HOSTNAME, CUBESQL_DEFAULT_PORT, USERNAME, PASSWORD, CUBESQL_DEFAULT_TIMEOUT, certificatePath) != CUBESQL_NOERR) { - goto abort; +abort: + do_print_ssl(); + if (db) { + printf("error %d in cubesql_connect: %s\n", cubesql_errcode(db), cubesql_errmsg(db)); + cubesql_disconnect(db, kFALSE); } + return -1; +} + +int do_test_tls (const char *rootCAFile) { + csqldb *db = NULL; do_print_ssl(); + if (cubesql_connect_token(&db, HOSTNAME, CUBESQL_DEFAULT_PORT, USERNAME, PASSWORD, CUBESQL_DEFAULT_TIMEOUT, CUBESQL_ENCRYPTION_SSL, NULL, kFALSE, NULL, rootCAFile, NULL, NULL) != CUBESQL_NOERR) goto abort; + do_test(db); // disconnect @@ -131,3 +137,11 @@ int main(int argc, const char * argv[]) { } return -1; } + + +int main(int argc, const char * argv[]) { + do_test_clear(); + do_test_tls(argv[1]); + + return 0; +}