views:

26

answers:

1

Hi all,

I would like to send some information to a 'HTTPS' server and get the cookies and html code from the server. I have already complete the cookies and the html part. However, when I use the 'GET' method to set the url and use the statusCode to see the http status code, I found that the status code is 0. I found the error is about the 'untrust server certificate'.

How can I add the certificate to the NSHTTPURLResponse in order to receive the 200 or 302 status code? The error display the Error Code = -1202. Thank you.

+1  A: 

Hi mark I had the same problem a few days ago, the following post solved it. Adding an untrusted certificate is (at least in the simulator) not possible, but you can tell your NSURLConnection Delegate to accept self signed certificates (or generally untrusted ones)

How to use NSURLConnection to connect with SSL for an untrusted cert?

hope i could help! cheers sam

samsam
thank you, sam. It is very useful. But I still have 1 questions, where should I put the code. I used to put the code within a .m class. But it did not work. I checked the apply developer website, I know those are pre-defined functions, but where should I call it? I also used to put the NSLog() to print the content, but I could not see the content of the NSLog. thank you very much.
Questions
ok, the methods mentionend in the the other article are delegate methods. the principle of delegate methods is that you hook up methods o a delegate object. I would recomend you to read some tutorials about the basic concept of delegates (it's the same in most programming languages). in your case the delegate methods would go in the .m file where you instantiate and invoke your NSURLConnection. simply set the delegate Object of your NSURLConnection object to self in that specific case.
samsam