-
Notifications
You must be signed in to change notification settings - Fork 212
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
Fixed an issue that would prevent attachments from being downloaded v… #332
Conversation
…ia SSL connections when using a custom CA ceritficate that was included in the bundle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
I have 2 cosmetic remarks and as per https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.rst, we also need you to sign off code changes. You can do a it in a comment like at #274 (comment)
@@ -232,6 +233,14 @@ - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticatio | |||
NSURLProtectionSpace *protectionSpace = [challenge protectionSpace]; | |||
if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) | |||
{ | |||
NSSet <NSData *> *certificates = [AFSecurityPolicy certificatesInBundle:[NSBundle mainBundle]]; | |||
if (certificates && certificates.count > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For code consistency, could you please add a new line before the opening bracket?
NSSet <NSData *> *certificates = [AFSecurityPolicy certificatesInBundle:[NSBundle mainBundle]]; | ||
if (certificates && certificates.count > 0) { | ||
NSMutableArray *pinnedCertificates = [NSMutableArray array]; | ||
for (NSData *certificateData in certificates) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.
oh, can you also change the base branch of this PR from "master" to "develop", please? |
…ed-off-by: Javier Quevedo <jquevedo@gmail.com>
Signed-off-by: Javier Quevedo jquevedo@gmail.com |
Great. Thanks for accepting it. Next one will go to develop instead of master :) |
…ia SSL connections when using a custom CA ceritficate that was included in the bundle.
Explanation:
All of the network operations use AFNetworking except for the download of files, which uses NSURLRequest. AFNetworking automatically checks which certificates are in the bundle and uses them to validate SSL connections. On the contrary, the MXMediaLoader class was relying only on those certificates that were manually accepted by the user. This could create a situation where all network connections worked, except for downloading media/attachments.
The MXMediaLoader now is capable of asking AFNetworking for those pinned certificates, and adds the CA to the chain of trust at the time of preparing the SSL negotiation.