Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom libcurl for retrieving SecTrustRefs from failed SSL/TLS connections #17

Open
wants to merge 36 commits into
base: v4.x-beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9b00bbf
Switch to darwinssl-get-trust branch of libcurl
mikeabdullah Dec 4, 2013
0e887b8
New build of libcurl from the darwinssl-get-trust branch of curl.
dodgio Dec 4, 2013
da15bf8
Report server trust back out for SSL_CACERT errors
mikeabdullah Dec 5, 2013
c0a46fe
Merge branch 'v4.x-beta' into darwinssl-get-trust
mikeabdullah Dec 9, 2013
b04d466
Update to be based off libcurl 7.34
mikeabdullah Jan 14, 2014
11972f9
Use c-ares d5d3871 since it has that nice update for automaker 1.14.
dodgio Jan 14, 2014
f18ae34
New release build of libcurl 7.34.0 and lib cares 1.10.0 d5d3871
dodgio Jan 14, 2014
73d8209
Merge branch 'v4.x-beta' into darwinssl-get-trust
mikeabdullah Jan 15, 2014
17ea1c2
Merge branch 'v4.x-beta' into darwinssl-get-trust
mikeabdullah Jan 15, 2014
bd28c79
Revert "New release build of libcurl 7.34.0 and lib cares 1.10.0 d5d3…
mikeabdullah Jan 16, 2014
32016eb
Exception handler to try and track down assertion failures
mikeabdullah Jan 20, 2014
d1470bc
Merge branch 'v4.x-beta' into darwinssl-get-trust
mikeabdullah Jan 22, 2014
008ea36
Merge branch 'v4.x-beta' into darwinssl-get-trust
mikeabdullah Jan 22, 2014
e599545
Merge branch 'v4.x-beta' into darwinssl-get-trust
mikeabdullah Jan 22, 2014
1daba1e
Handle libcurl producing slightly different error code dependent on OS
mikeabdullah Jan 24, 2014
9f98d98
Update libcurl to 7.36.0
dodgio Apr 10, 2014
c87b5aa
Build lib cares (same) and lib curl (7.36.0)
dodgio Apr 10, 2014
84dc28f
Store and retrieve SFTP/SSH hosts correctly in keychain
mikeabdullah Apr 21, 2014
2aaf854
Handle completion trying to happen more than once
mikeabdullah Apr 30, 2014
ce3155a
Report upload stream errors through to delegate
mikeabdullah Apr 30, 2014
57356fa
Switch to our customised libcurl 7.36.0
mikeabdullah May 2, 2014
71e9444
Revert "Build lib cares (same) and lib curl (7.36.0)"
mikeabdullah May 2, 2014
c644fb8
Modify configure scripts for libcares, libcurl so they don't include …
dodgio May 3, 2014
c1c7903
Build new versions of libcares, libcurl that are 10.8-safe.
dodgio May 3, 2014
cd7321b
Note - previous commit should have said 10.6 not 10.8: Build new vers…
dodgio May 3, 2014
ac8b6ff
SFTP keychain improvements
mikeabdullah Jul 12, 2014
448357e
mention another race case
mikeabdullah Sep 18, 2014
b94378b
Handle cancellation race condition
mikeabdullah Sep 18, 2014
4a3f3ae
Only treat warnings as errors for release builds
mikeabdullah Oct 7, 2014
b83b160
Switch to XCTest
mikeabdullah Oct 7, 2014
a66ac1e
Keychain handling tweaks to fix possible 10.6 bug
mikeabdullah Oct 20, 2014
24dcf4d
Merge branch 'v4.x-beta' into darwinssl-get-trust
mikeabdullah Jan 25, 2015
cf6c89c
Xcode insists on updating this
Mar 2, 2015
c0b51b1
Update to libssh2 v1.5
mikeabdullah Mar 12, 2015
188bf93
Merge pull request #20 from karelia/update-project
mikeabdullah Mar 17, 2015
73b43ae
Merge pull request #21 from karelia/libssh2-1.5
mikeabdullah Mar 17, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions CURLHandle.xcworkspace/xcshareddata/CURLHandle.xccheckout
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>C5075563-52EE-44A8-B9E1-A377845BD3C5</string>
<key>IDESourceControlProjectName</key>
<string>CURLHandle</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>3C62F561-1E26-4966-9AC6-33364805F345</key>
<string>https://github.com/karelia/libssh2_sftp-Cocoa-wrapper.git</string>
<key>681A9D27-DBCC-48A2-8B95-845A92E2CA7F</key>
<string>https://github.com/karelia/MockServer.git</string>
<key>71FE81F8-C42A-4A18-8697-2C888117D6FE</key>
<string>git://github.com/bagder/c-ares.git</string>
<key>9BCAF01B-6169-471D-826D-3DA4D252B0D6</key>
<string>ssh://github.com/karelia/CurlHandle.git</string>
<key>B29BEE58-D36B-4C7C-9922-79E808863BCA</key>
<string>https://github.com/karelia/curl.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>CURLHandle.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>3C62F561-1E26-4966-9AC6-33364805F345</key>
<string>../SFTP</string>
<key>681A9D27-DBCC-48A2-8B95-845A92E2CA7F</key>
<string>../CURLHandleSource/Tests/MockServer</string>
<key>71FE81F8-C42A-4A18-8697-2C888117D6FE</key>
<string>../c-ares</string>
<key>9BCAF01B-6169-471D-826D-3DA4D252B0D6</key>
<string>..</string>
<key>B29BEE58-D36B-4C7C-9922-79E808863BCA</key>
<string>../curl</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/karelia/CurlHandle.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>9BCAF01B-6169-471D-826D-3DA4D252B0D6</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>71FE81F8-C42A-4A18-8697-2C888117D6FE</string>
<key>IDESourceControlWCCName</key>
<string>c-ares</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>B29BEE58-D36B-4C7C-9922-79E808863BCA</string>
<key>IDESourceControlWCCName</key>
<string>curl</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>9BCAF01B-6169-471D-826D-3DA4D252B0D6</string>
<key>IDESourceControlWCCName</key>
<string>CurlHandle</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>681A9D27-DBCC-48A2-8B95-845A92E2CA7F</string>
<key>IDESourceControlWCCName</key>
<string>MockServer</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>3C62F561-1E26-4966-9AC6-33364805F345</string>
<key>IDESourceControlWCCName</key>
<string>SFTP</string>
</dict>
</array>
</dict>
</plist>
20 changes: 7 additions & 13 deletions CURLHandleSource/CURLHandle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
221EAD11160B167900E4F270 /* CURLMultiHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 221EAD0F160B167900E4F270 /* CURLMultiHandle.h */; };
221EAD12160B167900E4F270 /* CURLMultiHandle.m in Sources */ = {isa = PBXBuildFile; fileRef = 221EAD10160B167900E4F270 /* CURLMultiHandle.m */; };
221F8B7B17255229004E7B9D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
223FD095160B523700BE1C80 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 223FD094160B523700BE1C80 /* SenTestingKit.framework */; };
223FD0A1160B523700BE1C80 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 223FD09F160B523700BE1C80 /* InfoPlist.strings */; };
223FD0A4160B523700BE1C80 /* CURLMultiTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 223FD0A3160B523700BE1C80 /* CURLMultiTests.m */; };
223FD0AC160B5F1200BE1C80 /* CURLTransferTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 223FD0AB160B5F1200BE1C80 /* CURLTransferTests.m */; };
Expand Down Expand Up @@ -321,8 +320,7 @@
2213AA4B1709BC92003F2557 /* StandaloneGcdTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StandaloneGcdTest.m; sourceTree = "<group>"; };
221EAD0F160B167900E4F270 /* CURLMultiHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CURLMultiHandle.h; sourceTree = "<group>"; };
221EAD10160B167900E4F270 /* CURLMultiHandle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CURLMultiHandle.m; sourceTree = "<group>"; };
223FD092160B523700BE1C80 /* CURLHandleTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CURLHandleTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
223FD094160B523700BE1C80 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
223FD092160B523700BE1C80 /* CURLHandleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CURLHandleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
223FD09E160B523700BE1C80 /* CURLHandleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CURLHandleTests-Info.plist"; sourceTree = "<group>"; };
223FD0A0160B523700BE1C80 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
223FD0A3160B523700BE1C80 /* CURLMultiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CURLMultiTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -417,7 +415,6 @@
files = (
22BCCE3C16ADD73400DFFE8D /* (null) in Frameworks */,
22BCCE3316ADD66900DFFE8D /* Security.framework in Frameworks */,
223FD095160B523700BE1C80 /* SenTestingKit.framework in Frameworks */,
226B358D16ADAA6D004780A7 /* CURLHandle.framework in Frameworks */,
22F9473F1709C00000F0E6E1 /* libcurl.dylib in Frameworks */,
22F947401709C00B00F0E6E1 /* libcares.dylib in Frameworks */,
Expand Down Expand Up @@ -453,7 +450,7 @@
isa = PBXGroup;
children = (
8DC2EF5B0486A6940098B216 /* CURLHandle.framework */,
223FD092160B523700BE1C80 /* CURLHandleTests.octest */,
223FD092160B523700BE1C80 /* CURLHandleTests.xctest */,
22C9CFBF17035A0A004610FE /* Standalone Test */,
);
name = Products;
Expand Down Expand Up @@ -503,7 +500,6 @@
1058C7B0FEA5585E11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
223FD094160B523700BE1C80 /* SenTestingKit.framework */,
79B96CA70A6360E00060AC12 /* SystemConfiguration.framework */,
0867D69BFE84028FC02AAC07 /* Foundation.framework */,
27D77E151672BD9B0091EF91 /* Security.framework */,
Expand Down Expand Up @@ -716,8 +712,8 @@
);
name = CURLHandleTests;
productName = CURLHandleTests;
productReference = 223FD092160B523700BE1C80 /* CURLHandleTests.octest */;
productType = "com.apple.product-type.bundle";
productReference = 223FD092160B523700BE1C80 /* CURLHandleTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
22C9CFBE17035A0A004610FE /* Standalone Test */ = {
isa = PBXNativeTarget;
Expand Down Expand Up @@ -762,6 +758,7 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastTestingUpgradeCheck = 0600;
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = "Karelia Software";
};
Expand Down Expand Up @@ -1147,7 +1144,6 @@
"DEBUG=1",
"$(inherited)",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
Expand Down Expand Up @@ -1186,7 +1182,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_PREFIX_HEADER = "Tests/CURLHandleTests-Prefix.pch";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/built/include/curl-x86_64\"";
Expand All @@ -1197,15 +1193,14 @@
"\"$(SRCROOT)/built\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
};
name = Debug;
};
223FD0A8160B523700BE1C80 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_PREFIX_HEADER = "Tests/CURLHandleTests-Prefix.pch";
HEADER_SEARCH_PATHS = "\"$(SRCROOT)/built/include/curl-x86_64\"";
INFOPLIST_FILE = "Tests/CURLHandleTests-Info.plist";
Expand All @@ -1215,7 +1210,6 @@
"\"$(SRCROOT)/built\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>BC911206-022E-466C-872A-44136EEA430F</string>
<key>IDESourceControlProjectName</key>
<string>CURLHandle</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>3C62F561-1E26-4966-9AC6-33364805F345</key>
<string>https://github.com/karelia/libssh2_sftp-Cocoa-wrapper.git</string>
<key>681A9D27-DBCC-48A2-8B95-845A92E2CA7F</key>
<string>https://github.com/karelia/MockServer.git</string>
<key>71FE81F8-C42A-4A18-8697-2C888117D6FE</key>
<string>git://github.com/bagder/c-ares.git</string>
<key>9BCAF01B-6169-471D-826D-3DA4D252B0D6</key>
<string>ssh://github.com/karelia/CurlHandle.git</string>
<key>B29BEE58-D36B-4C7C-9922-79E808863BCA</key>
<string>https://github.com/karelia/curl.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>CURLHandleSource/CURLHandle.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>3C62F561-1E26-4966-9AC6-33364805F345</key>
<string>../../../SFTP</string>
<key>681A9D27-DBCC-48A2-8B95-845A92E2CA7F</key>
<string>../../Tests/MockServer</string>
<key>71FE81F8-C42A-4A18-8697-2C888117D6FE</key>
<string>../../../c-ares</string>
<key>9BCAF01B-6169-471D-826D-3DA4D252B0D6</key>
<string>../../..</string>
<key>B29BEE58-D36B-4C7C-9922-79E808863BCA</key>
<string>../../../curl</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/karelia/CurlHandle.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>9BCAF01B-6169-471D-826D-3DA4D252B0D6</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>71FE81F8-C42A-4A18-8697-2C888117D6FE</string>
<key>IDESourceControlWCCName</key>
<string>c-ares</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>B29BEE58-D36B-4C7C-9922-79E808863BCA</string>
<key>IDESourceControlWCCName</key>
<string>curl</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>9BCAF01B-6169-471D-826D-3DA4D252B0D6</string>
<key>IDESourceControlWCCName</key>
<string>CurlHandle</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>681A9D27-DBCC-48A2-8B95-845A92E2CA7F</string>
<key>IDESourceControlWCCName</key>
<string>MockServer</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>3C62F561-1E26-4966-9AC6-33364805F345</string>
<key>IDESourceControlWCCName</key>
<string>SFTP</string>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "223FD091160B523700BE1C80"
BuildableName = "CURLHandleTests.octest"
BuildableName = "CURLHandleTests.xctest"
BlueprintName = "CURLHandleTests"
ReferencedContainer = "container:CURLHandle.xcodeproj">
</BuildableReference>
Expand Down
57 changes: 43 additions & 14 deletions CURLHandleSource/CURLTransfer.m
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ - (void)cancel;

// Bounce over to doing suspension in background as libcurl sometimes blocks for a long time on that
dispatch_async(queue, ^{
// But of course by the time we arrive here, the transfer may have naturally
// completed, and so been removed from the multi. If so, reporting that to the
// delegate should already be taken care of and we can bail out early.
if (_state == CURLTransferStateCanceling) return;

[multi suspendTransfer:self];

// Report self as completed once any pending work on the queue is performed
Expand Down Expand Up @@ -662,6 +667,13 @@ - (void)completeWithCode:(CURLcode)code;

- (void)completeWithError:(NSError *)error;
{
// Ignore any attempt to complete after the first one
// This can happen when reading body data fails, there'll be one completion with the error from
// the stream, and then another error from libcurl that the transfer was aborted.
// Cancellation can also have a bit of a race condition where the transfer wants to cancel at
// the same time as it naturally finishes/fails
if (self.state == CURLTransferStateCompleted) return;

_error = [error copy];
_state = CURLTransferStateCompleted;

Expand Down Expand Up @@ -754,6 +766,31 @@ - (NSError*)errorForURL:(NSURL*)url code:(CURLcode)code
[userInfo release];


if (code == CURLE_PEER_FAILED_VERIFICATION || // seen on 10.7
code == CURLE_SSL_CACERT) // seen on 10.9
{
// Use Keith's patch to grab SecTrust. Have to hardcode the value for now
// until I figure out the build search paths properly
SecTrustRef trust;
if (curl_easy_getinfo(_handle, /*CURLINFO_SSL_TRUST = */ 0x500000 + 43, &trust) == CURLE_OK && trust)
{
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] initWithDictionary:result.userInfo];
[userInfo setObject:result forKey:NSUnderlyingErrorKey];
[userInfo setObject:(id)trust forKey:NSURLErrorFailingURLPeerTrustErrorKey];

result = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorSecureConnectionFailed userInfo:userInfo];
[userInfo release];
return result;
}

struct curl_certinfo *certInfo = NULL;
if (curl_easy_getinfo(_handle, CURLINFO_CERTINFO, &certInfo) == CURLE_OK)
{
// TODO: Extract something interesting from the certificate info. Unfortunately I seem to get back no info!
}
}


// Try to generate a Cocoa-friendly error on top of the raw libCurl one
switch (code)
{
Expand Down Expand Up @@ -825,17 +862,6 @@ - (NSError*)errorForURL:(NSURL*)url code:(CURLcode)code
result = [self errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable underlyingError:result];
break;

case CURLE_SSL_CACERT:
{
struct curl_certinfo *certInfo = NULL;
if (curl_easy_getinfo(_handle, CURLINFO_CERTINFO, &certInfo) == CURLE_OK)
{
// TODO: Extract something interesting from the certificate info. Unfortunately I seem to get back no info!
}

break;
}

/*
CURLE_REMOTE_ACCESS_DENIED would seem to translate to NSURLErrorNoPermissionsToReadFile quite
well. However, in practice it also happens when an FTP server rejected a CWD command because
Expand Down Expand Up @@ -1006,11 +1032,14 @@ - (size_t) curlSendDataTo:(void *)inPtr size:(size_t)inSize number:(size_t)inNum
result = [_uploadStream read:inPtr maxLength:inSize * inNumber];
if (result < 0)
{
NSError *error = [_uploadStream streamError];
[self completeWithError:error];

// Report error to transcript too. This may be unnecessary now; I'm just maintaining the
// existing setup until I have reason to change it (e.g. turns out there's dupes appearing)
[self tryToPerformSelectorOnDelegate:@selector(transfer:didReceiveDebugInformation:ofType:) usingBlock:^{

NSError *error = [_uploadStream streamError];

[self.delegate transfer:self
[self.delegate transfer:self
didReceiveDebugInformation:[NSString stringWithFormat:@"Read failed: %@", [error debugDescription]]
ofType:CURLINFO_HEADER_IN];
}];
Expand Down
Loading