Private
Public Access
1
0

Experimental SSL support

This commit is contained in:
James Magahern
2019-01-22 23:31:36 -08:00
parent 90775ebbba
commit 0cb907e2ad
18 changed files with 370 additions and 47 deletions

View File

@@ -10,18 +10,62 @@
#import "MBIMBridge.h"
int main(int argc, const char * argv[]) {
void printUsage()
{
fprintf(stderr, "Usage: kordophoned [-h] [-s | -c (certificate.p12)]\n");
fprintf(stderr, "\t-h \t Show this help message\n");
fprintf(stderr, "\t-s \t Use SSL (requires -c option)\n");
fprintf(stderr, "\t-c \t SSL certificate path encoded as pkcs12\n");
}
int main(int argc, char *const argv[]) {
@autoreleasepool {
MBIMBridge *bridge = [MBIMBridge sharedInstance];
BOOL usesSSL = NO;
BOOL showHelp = NO;
const char *certPath = NULL;
#if HOOK_IMAGENT
if (argc < 2) {
fprintf(stderr, "Usage: kordophoned agentHook.dylib\n");
int c = -1;
while ( (c = getopt(argc, argv, "hsc:")) != -1 ) {
switch (c) {
case 's':
usesSSL = YES;
break;
case 'c':
certPath = optarg;
break;
case 'h':
showHelp = YES;
break;
case '?':
if (optopt == 'c') {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
} else if (isprint(optopt)) {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
} else {
fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
return 1;
}
default:
abort ();
}
}
if (showHelp) {
printUsage();
return 1;
}
bridge.dylibPath = argv[1];
#endif
if (usesSSL && certPath == NULL) {
fprintf(stderr, "Error: wants SSL (-s) but no ssl certificate path (-c) provided\n");
return 1;
}
MBIMBridge *bridge = [MBIMBridge sharedInstance];
if (usesSSL && certPath != NULL) {
bridge.usesSSL = YES;
bridge.sslCertPath = [NSString stringWithCString:certPath encoding:NSASCIIStringEncoding];
}
[bridge connect];
@@ -30,5 +74,6 @@ int main(int argc, const char * argv[]) {
[[NSRunLoop currentRunLoop] run];
}
}
return 0;
}