Experimental SSL support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user