Does Alamofire work over HTTPS network? - swift

As the title says. Alamofire is an HTTP networking library written in Swift. But I want to know if it works over https network?
And is there any other library in swift for accessing an api and parse a json file?

As described in the official Alamofire document you can work also with HTTPS protocols but remember to enable NSAppTransportSecurity as described here (Stack Overflow answer)
P.S.: now there is the 3.4.0 version available, there is only one issue about SSL connections, you can find here
DETAILS:
As CouchDeveloper commented in this post , you must remember that with this configuration you actually bypass "App Transport Security", so you can control your white/black domains list in this dictionary by the NSExceptionDomains as documented in the Apple pages or in this useful page that discuss about "Working with Apple’s App Transport Security". This documentation explain how to restrict the app network access to handle the app security settings.

Related

Dyndns2 protocol specification?

I’m seeing a “DynDNS2” protocol referenced a lot but
I have a hard time locating its specification. AFAICS,
RFC 2136 is not versioned on the protocol level so I’m
inclined to rule that one out. Somehow I can find
numerous implementations of DynDNS2 but the repos I’ve
browsed don’t link to a canonical document either.
Example: https://support.google.com/domains/answer/6147083
– that’s Google claiming they support this protocol without
further explanation.
Where can I find the official specification of DynDNS2?
Who is in charge of its standardization and development?
The link (now) shows how to do so "manually":
https://username:password#domains.google.com/nic/update?hostname=subdomain.yourdomain.com&myip=1.2.3.4
And gives more specs.
You should check the link to the support page again and click the Using the API to update your Dynamic DNS record
Example HTTP query:
POST /nic/update?hostname=subdomain.yourdomain.com&myip=1.2.3.4 HTTP/1.1
Host: domains.google.com
Authorization: Basic base64-encoded-auth-string User-Agent: Chrome/41.0 your_email#yourdomain.com
Also you need to add the User Agent header to make sure your call is not ignored or worse, your client is blocked.
At source forge you can find a list of these dynamic DNS "protocols".
Dyn.com has quite good documentation on their site including flow diagram, update api and return codes
The RFC 2136 spec is an extension of the DNS itself and used by nsupdate command. It's complicated and is used by sysadmins.
Routers are using just a plain HTTP GET requests to some DDNS provider. Their urls are looking the same as original Dyn.com have: /nic/update?hostname=[DOMAIN]&myip=[IP].
See:
https://openwrt.org/docs/guide-user/services/ddns/client
https://sourceforge.net/p/ddclient/wiki/protocols/

Download a file from server using HTPPS Protocol

I want to download a file from server using https protocol I am using NSUrlConnection but that would not work.any sample code is appreciated
I'd recommend using ASIHTTPRequest which is a great library for handling web services. You can of course roll your own with NSURLConnection, but the advantage of the library is that it handles all the authentication and certificate issues that can arise and generally gives you a more robust and generic solution.
Post some code if you'd rather not use the library, I suspect it might be you are accessing a site that doesn't have a fully valid certificate as IIRC the default behaviour of the iOS is to reject the certificates unless you explicitly allow them as this is the more secure option.
Checkout ASIHTTPRequest
,Use it for network related stuff. Really useful.

iPhone web service calls to WCF Service with Certificate Authentication

We are a .Net shop that has standardized on WCF Services. We are in the processs of developing an iPhone application that needs to make secure web services calls to obtain data for the app. To ensure secure communiations we have enabled SSL on our web servers. But this does not ensure the service can only be consumed by authorized apps. We have configured our services to support x509 certificate authentication. Is it even possible to call a secure WCF service with certifcate authentication from an IPhone app?
I have spent many hours searching the internet for examples but to no avail. I HAVE been able to successfuly call an un-secure WCF service with no issues. I have also done a lot of research on the WS-Security and WS-Trust communications standards. I believe I understand how this should work. I am just having trouble piecing together the steps/objects within the iPhone frameworks I need to make this work.
Any thoughts and ideas on the subject would be greatly appreciated.
Also, any thoughts on any of the following:
How best to deploy the P12 certifcate file with the iPhone application
How best to secure the password for the P12 file within the app
Is deploying the P12 file with the app a best practice
Are there facilties within the iPhone frameworks to support this kind of secure communication? If not, what would be an alternative recommendation.
For starters, I'd say if you are really serious about security please dedicate the proper time and resources to it and treat it like a first class citizen in your feature list. Don't just "turn on SSL" and pretend things are secure. I'm not suggesting you are doing this or not doing this, but I just feel like I have to say it before proceeding.
That said, you probably already know that WS-* is all built on top of http requests, and any time you are doing loads of http requests, you'll probably find ASIHTTPRequest very helpful on the iPhone. However, that will not get you 100% of the way there.
From the iPhone's perspective you have:
The URL loading system, which is a high level API for dealing with network resources of any kind
The CFNetwork C API which is lower-level and allows you a great deal more control of encrypting streams and network traffic any way you see fit
The Certificate, Key, and Trust Services that do the heavy lifting, and more specifically the X509 trust policies
On Macs you get to use Secure Transport, but as far as I know they haven't ported that to the device so I wouldn't get too distracted reading up on that unless you are planning on bringing this to the desktop or are just in the mood to learn everything :)
If you are doing any security with WCF, the first thing you probably realized is that there are many options available to you, but it all boils down to this short list:
Transport layer security (https) with clear text messages (xml/json/...)
Message layer security (encrypted message body) over an open transport (http)
Secured messages over a secured transport
The last time I was doing WCF (about a year ago) the general recommendation from Microsoft seemed to be Message layer security over an open transport because of firewall / accessibility issues introduced when trying to secure the transport. However, this approach assumed that all parties involved were .NET / WCF capable. I believe it would be easier to consume on the device if it were an HTTPS transport level security, with clear XML or JSON message bodies. That way you can take advantage of all the stuff baked into CFNetwork and NSHTTPRequest that Apple has done.
Once you get something working, you'll want to refer to the Enterprise Deployment Guide, and specifically the documentation on Over-the-Air Enrollment so that you can install the certificates on the devices. Remember, anything is possible, and don't be afraid to use one of those Apple support tickets that come with the program :)
EDIT:
I completely forgot to mention the GenericKeychain and CryptoExcercise examples
EDIT 2:
After I got downvoted for no apparent reason I re-read my response and realized I rambled a bit too much without actually answering your question about how to open a p12 file on the device. You ought to be able to simply [[UIApplication sharedApplication] openURL:urlToP12FileEitherLocalOrRemote]] and have it kick out to the OS for the installation procedure.
You can also use ssl + user/pass authentication at the message level.
Generally, if you want to install certificates on the iPhone, there are two options I have found (both of them from here):
Email the certificate to the recipient. If it is a valid certificate and the headers in the email are in order, then it will allow the recipient of the email to install the certificate. The problem here of course is a man-in-the-middle attack.
Use the iPhone enterpirse configuration utlity.
That should get you part of the way there (installing the certificate locally). I should note that in general, you don't want to install one certifiate for the entire application, but have separate certificates for your users. As a general practice, authenticating the application is a very bad thing, whereas you should be authenticating the user.
However, if you are authenticating the user already, then this shouldn't be an issue, as using basic authentication over HTTPS would work just as well (and easier to code).
I agree with Yaron Naveh's solution too, probably the best bet is to use SSL. I believe SSL/TLS encryption is better performance wise than message/XML based encryption in WCF too.
I think the certificate would probably need to be from a trusted CA (certificate authority) for this to work though. From memory, I had difficulty with the iPhone SDK with self-signed certificates, but that may well have changed in the last year...
An iPhone should be able to access a Certificate-secured WCF application. If you make your WCF service a RP of Azure ACS it should work using OAuth among other methods.
Take a look at the samples here for more: http://acs.codeplex.com/

tclsoap and ssl

Can anyone provide a working example of using tclSOAP with SSL? The links referred to in the official docs aren't working http://tclsoap.sourceforge.net I'm unsure how to configure the transport protocol.
If you haven't already I'd post your question here. The maintainers of TCLSoap are more likely to see it and respond to it.

What common backend can be accessed securely from an iPhone and Android application?

I'm thinking about creating an application for the iPhone and Android that will need to access a common backend to retrieve account information. Can both access a web service over https? What other way would allow me to have one interface to the backend that is accessible by both?
They both work over http and https which is a common enough protocol. I would suggest you go with a RESTful web service so you expose your service via URI's like http://www.myservice.com/weather/zip/98007 which would return an XML blob that can be parsed by the client.
if you are starting from nothing, i'd definitely go with RESTful service that returns/accepts JSON... there are plenty of libraries for both platforms that will accept JSON and turn it into arrays and dictionaries.
I'd recommend using a RESTful web service backend, which is all standard HTTP and/or HTTPS. If you can use Ruby on Rails, its default scaffolding will get you about 99% of the way there and for the iPhone there is an open source project called ObjectiveResource that will automate your communication with this Rails backend. I haven't investigated yet what options are available on Android but since it is all simple HTTP it should be straightforward. I am not the maintainer of ObjectiveResource but I have contributed some code. You can check it out here:
http://iphoneonrails.com
One good approach I have seen used with other services is to write the backend in such a way that it can feed data back in different types - for Android an XML response is best, but for the iPhone sending back plist data is preferred (though it can also work with XML if required). In both cases it's easier to simply POST updates back to the server than to wrap an update in XML.
Both platforms should be able to use whatever form of authentication you wish to use, the iPhone I know supports all methods of HTTP authentication.