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

ssl pinning in vox #30

Open
ZahraAsgharzadeh opened this issue Nov 14, 2019 · 4 comments
Open

ssl pinning in vox #30

ZahraAsgharzadeh opened this issue Nov 14, 2019 · 4 comments

Comments

@ZahraAsgharzadeh
Copy link

I want to implement ssl pinning in Vox , Could you please help me how to do it ?

@ZahraAsgharzadeh
Copy link
Author

I found out by my self , it's good to support it when you publish a framework ... some body should waste his time to edit library .

@markturnip
Copy link

I found out by my self , it's good to support it when you publish a framework ... some body should waste his time to edit library .

Perhaps you can provide some example code on your approach?

@ZahraAsgharzadeh
Copy link
Author

I found out by my self , it's good to support it when you publish a framework ... some body should waste his time to edit library .

Perhaps you can provide some example code on your approach?

of course.
I'll put example in next comment 👍

@ZahraAsgharzadeh
Copy link
Author

ZahraAsgharzadeh commented Feb 27, 2020

In your project Go to Pods folder, open Vox.
Open JSONAPIClient_Alamofire.swift which module that all requests handles there .
In function executeRequest(...) add this part of code :

/// Configure the trust policy manager let serverTrustPolicy = ServerTrustPolicy.pinCertificates( certificates: ServerTrustPolicy.certificates(), validateCertificateChain: false, validateHost: true)

let serverTrustPolicies = ["yourhost.com": serverTrustPolicy]
let serverTrustPolicyManager = ServerTrustPolicyManager(policies: serverTrustPolicies)
let url = baseURL.appendingPathComponent(path)
let headers: HTTPHeaders = [ "Content-Type": "application/vnd.api+json", "Accept": "application/vnd.api+json", "Authorization": "token"]

/// using certificate pinning
let sessionManager = SessionManager(configuration: URLSessionConfiguration.default,serverTrustPolicyManager: serverTrustPolicyManager)
let request = multiEncodedURLRequest(url: url, method: method, queryItems: queryItems, bodyParameters: bodyParameters, headers: headers)

And when request sent, in responseData call back do
let _ = sessionManager
base on this link : https://stackoverflow.com/questions/39984880/alamofire-result-failure-error-domain-nsurlerrordomain-code-999-cancelled

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

No branches or pull requests

2 participants