Vox icon indicating copy to clipboard operation
Vox copied to clipboard

ssl pinning in vox

Open ZahraAsgharzadeh opened this issue 6 years ago • 4 comments

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

ZahraAsgharzadeh avatar Nov 14 '19 04:11 ZahraAsgharzadeh

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 .

ZahraAsgharzadeh avatar Jan 02 '20 12:01 ZahraAsgharzadeh

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?

markturnip avatar Feb 20 '20 01:02 markturnip

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 avatar Feb 27 '20 19:02 ZahraAsgharzadeh

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

ZahraAsgharzadeh avatar Feb 27 '20 19:02 ZahraAsgharzadeh