Index: src/OFHTTPClient.h ================================================================== --- src/OFHTTPClient.h +++ src/OFHTTPClient.h @@ -48,11 +48,11 @@ * @param client The OFHTTPClient that created a socket * @param socket The socket created by the OFHTTPClient * @param request The request for which the socket was created */ - (void)client: (OFHTTPClient*)client - didCreateSocket: (OFTCPSocket*)socket + didCreateSocket: (OF_KINDOF(OFTCPSocket*))socket request: (OFHTTPRequest*)request; /*! * @brief A callback which is called when an OFHTTPClient received headers. * Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -27,10 +27,11 @@ #import "OFHTTPResponse.h" #import "OFOptionsParser.h" #import "OFStdIOStream.h" #import "OFSystemInfo.h" #import "OFTCPSocket.h" +#import "OFTLSSocket.h" #import "OFURL.h" #import "OFLocalization.h" #import "OFAddressTranslationFailedException.h" #import "OFConnectionFailedException.h" @@ -54,11 +55,11 @@ { OFArray OF_GENERIC(OFString*) *_URLs; size_t _URLIndex; int _errorCode; OFString *_outputPath; - bool _continue, _force, _detectFileName, _quiet, _verbose; + bool _continue, _force, _detectFileName, _quiet, _verbose, _insecure; OFDataArray *_body; of_http_request_method_t _method; OFMutableDictionary *_clientHeaders; OFHTTPClient *_HTTPClient; char *_buffer; @@ -100,11 +101,13 @@ @"-P --proxy " @" Specify SOCKS5 proxy\n " @"-q --quiet " @" Quiet mode (no output, except errors)\n " @"-v --verbose " - @" Verbose mode (print headers)\n")]; + @" Verbose mode (print headers)\n " + @" --insecure " + @" Ignore TLS errors\n")]; [OFApplication terminateWithStatus: status]; } @implementation OFHTTP @@ -239,10 +242,11 @@ { 'o', @"output", 1, NULL, &outputPath }, { 'O', @"detect-filename", 0, &_detectFileName, NULL }, { 'P', @"socks5-proxy", 1, NULL, NULL }, { 'q', @"quiet", 0, &_quiet, NULL }, { 'v', @"verbose", 0, &_verbose, NULL }, + { '\0', @"insecure", 0, &_insecure, NULL }, { '\0', nil, 0, NULL, NULL } }; OFOptionsParser *optionsParser = [OFOptionsParser parserWithOptions: options]; of_unichar_t option; @@ -344,10 +348,19 @@ } [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } + +- (void)client: (OFHTTPClient*)client + didCreateSocket: (OF_KINDOF(OFTCPSocket*))socket + request: (OFHTTPRequest*)request +{ + if (_insecure && [socket respondsToSelector: + @selector(setCertificateVerificationEnabled:)]) + [socket setCertificateVerificationEnabled: false]; +} - (bool)client: (OFHTTPClient*)client shouldFollowRedirect: (OFURL*)URL statusCode: (int)statusCode request: (OFHTTPRequest*)request @@ -420,13 +433,13 @@ } @catch (OFUnsupportedProtocolException *e) { if (!_quiet) [of_stdout writeString: @"\n"]; [of_stderr writeString: OF_LOCALIZED(@"no_ssl_library", - @"%[prog]: No SSL library loaded!\n" + @"%[prog]: No TLS library loaded!\n" @" In order to download via https, you need to preload an " - @"SSL library for ObjFW\n" + @"TLS library for ObjFW\n" "such as ObjOpenSSL!\n", @"prog", [OFApplication programName])]; } @catch (OFReadOrWriteFailedException *e) { OFString *error = OF_LOCALIZED( @"download_failed_read_or_write_failed_any", Index: utils/ofhttp/lang/de.json ================================================================== --- utils/ofhttp/lang/de.json +++ utils/ofhttp/lang/de.json @@ -3,21 +3,22 @@ "full_usage": [ "\n", "Optionen:\n", " -b --body Angegebene Datei als Body übergeben\n", " -c --continue Download von existierender Datei ", - "fortsetzen\n", + "fortsetzen\n", " -f --force Existierende Datei überschreiben\n", " -h --help Diese Hilfe anzeigen\n", " -H --header Einen Header (z.B. X-Foo:Bar) hinzufügen\n", " -m --method HTTP Request-Methode setzen\n", " -o --output Ausgabe-Dateiname angeben\n", " -O --detect-filename Dateiname mittels HEAD-Request ermitteln\n", " -P --proxy SOCKS5-Proxy angeben\n", " -q --quiet Ruhiger Modus (keine Ausgabe außer Fehler)", - "\n", - " -v --verbose Geschwätziger Modus (gibt Header aus)\n" + "\n", + " -v --verbose Geschwätziger Modus (gibt Header aus)\n", + " --insecure TLS-Fehler ignorieren\n" ], "invalid_input_header": [ "%[prog]: Header müssen im Format Name:Wert sein!\n" ], "invalid_input_method": "%[prog]: Ungültige Request-Methode %[method]!\n", @@ -27,15 +28,15 @@ "takes_no_argument": "%[prog]: Option --%[opt] nimmt kein Argument\n", "unknown_long_option": "%[prog]: Unbekannte Option: --%[opt]\n", "unknown_option": "%[prog]: Unbekannte Option: -%[opt]\n", "quiet_xor_verbose": [ "%[prog]: -q / --quiet und -v / --verbose schließen sich gegenseitig ", - "aus!\n" + "aus!\n" ], "output_only_with_one_url": [ "%[prog]: -o / --output kann nicht mit mehr als einer URL benutzt ", - "werden!\n" + "werden!\n" ], "download_failed_address_translation": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " Adressauflösung fehlgeschlagen: %[exception]\n" ], @@ -46,12 +47,12 @@ "download_failed_invalid_server_reply": [ "%[prog]: Fehler beim Download von <%[url]>!\n", " Ungültige Antwort vom Server!\n" ], "no_ssl_library": [ - "%[prog]: Keine SSL-Bibliothek geladen!\n", - " Um Dateien über https zu laden, müssen Sie eine SSL-Bibliothek für ", + "%[prog]: Keine TLS-Bibliothek geladen!\n", + " Um Dateien über https zu laden, müssen Sie eine TLS-Bibliothek für ", "ObjFW,\n", " wie z.B. ObjOpenSSL, mittels LD_PRELOAD laden." ], "download_failed_read_or_write_failed_any": "Lesen oder Schreiben", "download_failed_read_or_write_failed_read": "Lesen",