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

Fixed an issue that would prevent attachments from being downloaded v… #332

Merged
merged 2 commits into from
Jul 19, 2017

Conversation

javierquevedo
Copy link
Contributor

…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.

…ia SSL connections when using a custom CA ceritficate that was included in the bundle
Copy link
Contributor

@manuroe manuroe left a 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) {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing.

@manuroe
Copy link
Contributor

manuroe commented Jul 19, 2017

oh, can you also change the base branch of this PR from "master" to "develop", please?
master contains only the code we have released.

…ed-off-by: Javier Quevedo <jquevedo@gmail.com>
@javierquevedo
Copy link
Contributor Author

Signed-off-by: Javier Quevedo jquevedo@gmail.com

@manuroe manuroe changed the base branch from master to develop July 19, 2017 13:46
@manuroe manuroe merged commit 0a62bb3 into matrix-org:develop Jul 19, 2017
@javierquevedo
Copy link
Contributor Author

Great. Thanks for accepting it. Next one will go to develop instead of master :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants