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

Need To Avoid SSL Problems #4

Open
loinsir opened this issue May 12, 2022 · 3 comments · May be fixed by #5
Open

Need To Avoid SSL Problems #4

loinsir opened this issue May 12, 2022 · 3 comments · May be fixed by #5

Comments

@loinsir
Copy link

loinsir commented May 12, 2022

In Chapter 10, net.sci.gsfc.nasa.gov api has a ssl problem.

@gordonbeijing
Copy link

Facing the same issue :(

@loinsir
Copy link
Author

loinsir commented May 19, 2022

To @gordonbeijing .

Finally, I solved this issue.

You should implement URLSessionDelegate in EONET.swift like this:

extension EONET: URLSessionDelegate {
  func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
    
    //accept all certs when testing, perform default handling otherwise
    completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
  }
}

and you should create your URLSession request like this:

return URLSession(configuration: .ephemeral,
                        delegate: EONET(), delegateQueue: nil).rx.response(request: request)

I hope you can solve this problem smoothly. :)

@gordonbeijing
Copy link

To @loinsir .

Thanks a lot ! It works well.

At first it didn't work after I modifying the codes according to your solution. I checked the error message, it was not the same as before. So I doubt it may be caused by some mysterious strength , and after I enabling the proxy, it works as expected 🥳

Anyway, thanks again!

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 a pull request may close this issue.

2 participants