add public key pinning in alamofire manger class swift2019 Community Moderator ElectionSwift Completion Blocks with Closures using AFNetworkingSwift Alamofire, only sends 4 post requestsTableView not displaying text with JSON data from API callAlamofire 4.0 - Set request content typeSwift gzipped responseIssue with the alamofire wrapper class with objectmapper in swift3Can't make post request using params as dictionary with Swift 4 & AlamofireSwift ios alamofire put request error Thread 1: signal SIGABRT atconnect with Windows SSL server through iOS app using alamofireDecode Alamofire response with JSONDecoder

The (Easy) Road to Code

How to recover against Snake as a heavyweight character?

Generating a list with duplicate entries

Can I challenge the interviewer to give me a proper technical feedback?

Should I file my taxes? No income, unemployed, but paid 2k in student loan interest

What exactly is the meaning of "fine wine"?

Limpar string com Regex

Paper published similar to PhD thesis

Does an unused member variable take up memory?

Inorganic chemistry handbook with reaction lists

How to educate team mate to take screenshots for bugs with out unwanted stuff

I am the person who abides by rules but breaks the rules . Who am I

Why is there an extra space when I type "ls" on the Desktop?

Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?

Was this cameo in Captain Marvel computer generated?

How can I portion out frozen cookie dough?

An Undercover Army

Tabular environment - text vertically positions itself by bottom of tikz picture in adjacent cell

What is Tony Stark injecting into himself in Iron Man 3?

How to make sure I'm assertive enough in contact with subordinates?

Why do phishing e-mails use faked e-mail addresses instead of the real one?

Averaging over columns while ignoring zero entries

Where is the License file location for Identity Server in Sitecore 9.1?

Issue with units for a rocket nozzle throat area problem



add public key pinning in alamofire manger class swift



2019 Community Moderator ElectionSwift Completion Blocks with Closures using AFNetworkingSwift Alamofire, only sends 4 post requestsTableView not displaying text with JSON data from API callAlamofire 4.0 - Set request content typeSwift gzipped responseIssue with the alamofire wrapper class with objectmapper in swift3Can't make post request using params as dictionary with Swift 4 & AlamofireSwift ios alamofire put request error Thread 1: signal SIGABRT atconnect with Windows SSL server through iOS app using alamofireDecode Alamofire response with JSONDecoder










0















here is my alamofire manager, how I can add public key pinning on it ? please help me, I couldn't know the way to do it in my code, if possible I need explanation step by step on how do that with AFManager that has all the requests



class AFManager : NSObject


///without headers (post)
//used this to registration
class func requestPOSTURL(_ strURL : String, params : [String :
AnyObject]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
URLCache.shared.removeAllCachedResponses()
Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody).responseJSON (responseObject) -> Void in

//print(responseObject)

if responseObject.result.isSuccess
let resJson = JSON(responseObject.result.value!)
success(resJson)

if responseObject.result.isFailure
let error : Error = responseObject.result.error!
failure(error)





///// response string (post)
//used this in login // used in change password
class func strRequestPOSTURL(_ strURL : String, params : [String : String]?, headers : [String : String]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
URLCache.shared.removeAllCachedResponses()
Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody, headers: headers).responseJSON (response) in
//print(response)

if response.result.isSuccess
let resJson = JSON(response.result.value!)
success(resJson)

if response.result.isFailure
let error : Error = response.result.error!

failure(error)









I saw this sample but didn't know how to do it and where I should put the code see the link below :
https://infinum.co/the-capsized-eight/ssl-pinning-revisited










share|improve this question


























    0















    here is my alamofire manager, how I can add public key pinning on it ? please help me, I couldn't know the way to do it in my code, if possible I need explanation step by step on how do that with AFManager that has all the requests



    class AFManager : NSObject


    ///without headers (post)
    //used this to registration
    class func requestPOSTURL(_ strURL : String, params : [String :
    AnyObject]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
    URLCache.shared.removeAllCachedResponses()
    Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody).responseJSON (responseObject) -> Void in

    //print(responseObject)

    if responseObject.result.isSuccess
    let resJson = JSON(responseObject.result.value!)
    success(resJson)

    if responseObject.result.isFailure
    let error : Error = responseObject.result.error!
    failure(error)





    ///// response string (post)
    //used this in login // used in change password
    class func strRequestPOSTURL(_ strURL : String, params : [String : String]?, headers : [String : String]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
    URLCache.shared.removeAllCachedResponses()
    Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody, headers: headers).responseJSON (response) in
    //print(response)

    if response.result.isSuccess
    let resJson = JSON(response.result.value!)
    success(resJson)

    if response.result.isFailure
    let error : Error = response.result.error!

    failure(error)









    I saw this sample but didn't know how to do it and where I should put the code see the link below :
    https://infinum.co/the-capsized-eight/ssl-pinning-revisited










    share|improve this question
























      0












      0








      0








      here is my alamofire manager, how I can add public key pinning on it ? please help me, I couldn't know the way to do it in my code, if possible I need explanation step by step on how do that with AFManager that has all the requests



      class AFManager : NSObject


      ///without headers (post)
      //used this to registration
      class func requestPOSTURL(_ strURL : String, params : [String :
      AnyObject]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
      URLCache.shared.removeAllCachedResponses()
      Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody).responseJSON (responseObject) -> Void in

      //print(responseObject)

      if responseObject.result.isSuccess
      let resJson = JSON(responseObject.result.value!)
      success(resJson)

      if responseObject.result.isFailure
      let error : Error = responseObject.result.error!
      failure(error)





      ///// response string (post)
      //used this in login // used in change password
      class func strRequestPOSTURL(_ strURL : String, params : [String : String]?, headers : [String : String]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
      URLCache.shared.removeAllCachedResponses()
      Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody, headers: headers).responseJSON (response) in
      //print(response)

      if response.result.isSuccess
      let resJson = JSON(response.result.value!)
      success(resJson)

      if response.result.isFailure
      let error : Error = response.result.error!

      failure(error)









      I saw this sample but didn't know how to do it and where I should put the code see the link below :
      https://infinum.co/the-capsized-eight/ssl-pinning-revisited










      share|improve this question














      here is my alamofire manager, how I can add public key pinning on it ? please help me, I couldn't know the way to do it in my code, if possible I need explanation step by step on how do that with AFManager that has all the requests



      class AFManager : NSObject


      ///without headers (post)
      //used this to registration
      class func requestPOSTURL(_ strURL : String, params : [String :
      AnyObject]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
      URLCache.shared.removeAllCachedResponses()
      Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody).responseJSON (responseObject) -> Void in

      //print(responseObject)

      if responseObject.result.isSuccess
      let resJson = JSON(responseObject.result.value!)
      success(resJson)

      if responseObject.result.isFailure
      let error : Error = responseObject.result.error!
      failure(error)





      ///// response string (post)
      //used this in login // used in change password
      class func strRequestPOSTURL(_ strURL : String, params : [String : String]?, headers : [String : String]?, success:@escaping (JSON) -> Void, failure:@escaping (Error) -> Void)
      URLCache.shared.removeAllCachedResponses()
      Alamofire.request(strURL, method: .post, parameters: params, encoding: URLEncoding.httpBody, headers: headers).responseJSON (response) in
      //print(response)

      if response.result.isSuccess
      let resJson = JSON(response.result.value!)
      success(resJson)

      if response.result.isFailure
      let error : Error = response.result.error!

      failure(error)









      I saw this sample but didn't know how to do it and where I should put the code see the link below :
      https://infinum.co/the-capsized-eight/ssl-pinning-revisited







      swift request alamofire public-key-pinning






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      Rooh Al-mahabaRooh Al-mahaba

      521412




      521412






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I would recommend using TrustKit. It is a dedicated library that works with everything base on NSURLSession, including Alamofire. Depending on your use case it may be as simple as adding a few values to Info.plist.



          Certificate pinning, same as any security measure, is not something you should implement yourself, but you should use a proven library.






          share|improve this answer

























          • It looks very useful library thank you very much, but can you explain what is valid pin and backup pin in the demo because I didn't get it, and I don't know much about that, I have only one public key is that the valid pin? and from where I get the backup key

            – Rooh Al-mahaba
            yesterday











          • The repo contains a script that generates a hash from the certificate. This is called a pin. This is probably what you have. The backup pin is a has of a certificate that could be used in case of some problems in the backend. You do not have to provide a real one, you have to can make it up.

            – Igor Kulman
            yesterday











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023487%2fadd-public-key-pinning-in-alamofire-manger-class-swift%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I would recommend using TrustKit. It is a dedicated library that works with everything base on NSURLSession, including Alamofire. Depending on your use case it may be as simple as adding a few values to Info.plist.



          Certificate pinning, same as any security measure, is not something you should implement yourself, but you should use a proven library.






          share|improve this answer

























          • It looks very useful library thank you very much, but can you explain what is valid pin and backup pin in the demo because I didn't get it, and I don't know much about that, I have only one public key is that the valid pin? and from where I get the backup key

            – Rooh Al-mahaba
            yesterday











          • The repo contains a script that generates a hash from the certificate. This is called a pin. This is probably what you have. The backup pin is a has of a certificate that could be used in case of some problems in the backend. You do not have to provide a real one, you have to can make it up.

            – Igor Kulman
            yesterday
















          0














          I would recommend using TrustKit. It is a dedicated library that works with everything base on NSURLSession, including Alamofire. Depending on your use case it may be as simple as adding a few values to Info.plist.



          Certificate pinning, same as any security measure, is not something you should implement yourself, but you should use a proven library.






          share|improve this answer

























          • It looks very useful library thank you very much, but can you explain what is valid pin and backup pin in the demo because I didn't get it, and I don't know much about that, I have only one public key is that the valid pin? and from where I get the backup key

            – Rooh Al-mahaba
            yesterday











          • The repo contains a script that generates a hash from the certificate. This is called a pin. This is probably what you have. The backup pin is a has of a certificate that could be used in case of some problems in the backend. You do not have to provide a real one, you have to can make it up.

            – Igor Kulman
            yesterday














          0












          0








          0







          I would recommend using TrustKit. It is a dedicated library that works with everything base on NSURLSession, including Alamofire. Depending on your use case it may be as simple as adding a few values to Info.plist.



          Certificate pinning, same as any security measure, is not something you should implement yourself, but you should use a proven library.






          share|improve this answer















          I would recommend using TrustKit. It is a dedicated library that works with everything base on NSURLSession, including Alamofire. Depending on your use case it may be as simple as adding a few values to Info.plist.



          Certificate pinning, same as any security measure, is not something you should implement yourself, but you should use a proven library.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered 2 days ago









          Igor KulmanIgor Kulman

          12.7k843106




          12.7k843106












          • It looks very useful library thank you very much, but can you explain what is valid pin and backup pin in the demo because I didn't get it, and I don't know much about that, I have only one public key is that the valid pin? and from where I get the backup key

            – Rooh Al-mahaba
            yesterday











          • The repo contains a script that generates a hash from the certificate. This is called a pin. This is probably what you have. The backup pin is a has of a certificate that could be used in case of some problems in the backend. You do not have to provide a real one, you have to can make it up.

            – Igor Kulman
            yesterday


















          • It looks very useful library thank you very much, but can you explain what is valid pin and backup pin in the demo because I didn't get it, and I don't know much about that, I have only one public key is that the valid pin? and from where I get the backup key

            – Rooh Al-mahaba
            yesterday











          • The repo contains a script that generates a hash from the certificate. This is called a pin. This is probably what you have. The backup pin is a has of a certificate that could be used in case of some problems in the backend. You do not have to provide a real one, you have to can make it up.

            – Igor Kulman
            yesterday

















          It looks very useful library thank you very much, but can you explain what is valid pin and backup pin in the demo because I didn't get it, and I don't know much about that, I have only one public key is that the valid pin? and from where I get the backup key

          – Rooh Al-mahaba
          yesterday





          It looks very useful library thank you very much, but can you explain what is valid pin and backup pin in the demo because I didn't get it, and I don't know much about that, I have only one public key is that the valid pin? and from where I get the backup key

          – Rooh Al-mahaba
          yesterday













          The repo contains a script that generates a hash from the certificate. This is called a pin. This is probably what you have. The backup pin is a has of a certificate that could be used in case of some problems in the backend. You do not have to provide a real one, you have to can make it up.

          – Igor Kulman
          yesterday






          The repo contains a script that generates a hash from the certificate. This is called a pin. This is probably what you have. The backup pin is a has of a certificate that could be used in case of some problems in the backend. You do not have to provide a real one, you have to can make it up.

          – Igor Kulman
          yesterday




















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023487%2fadd-public-key-pinning-in-alamofire-manger-class-swift%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко