ios - Print at console the information of a website -
i've made server runs https website. want print out information of website on console in xcode.
to that, added following viewcontroller.m
:
- (void)viewdidload { [super viewdidload]; nserror *error; nsstring *address = [nsstring stringwithformat: @"https://54.169.239.78:3001"]; nsurl *url = [nsurl urlwithstring:address]; nsstring *theweb = [nsstring stringwithcontentsofurl:url encoding:nsasciistringencoding error:&error]; nslog(@"%@", theweb); }
however, results (null)
. in addition, error:
nsurlsession/nsurlconnection http load failed (kcfstreamerrordomainssl, -9813)
even though have allowed app transport security in info.plist
what's wrong?
issue certificate only. if have set plist this.
if want verify thing change url (https://developer.apple.com/) of website in code , update code as:
- (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. nserror *error; nsstring *address = [nsstring stringwithformat: @"https://developer.apple.com/"]; nsurl *url = [nsurl urlwithstring:address]; nsstring *theweb = [nsstring stringwithcontentsofurl:url encoding:nsasciistringencoding error:&error]; nslog(@"%@", theweb); }
i have tried has displayed content.
you need real ssl certificate. here link certificates regarding details , self signed certificates have been discussed on here: certificate details
Comments
Post a Comment