Blog

Serverless Architecture| Tech Shorts | Quick Look

Serverless architecture, refer to the application that significantly depends on third party services or custom code that’s run with in ephemeral containers, AWS Lambda is the best-known example.

As the name suggests it not like that code is running without servers, here the code written in traditional server style such as micro services so pricing the based on the actual amount of resources consumed by application rather than on pre-purchased units of capacity.

Advantages:

Cost, effective because it not like renting or purchasing fixed quality of servers even it’s more cost effective than provisioning an autoscaling group.

Operations, as developers and operators do not need to spend time for setting up and tuning auto scaling policies.

Productivity, the units of code exposed to the outside world are simple functions. means programmer does not need to worry about multithreading or HTTP directly requests.

Disadvantages:

Performance, Infrequently used serverless code may suffer from greater response latency than a dedicated server.

Monitoring and debugging, diagnosing performance or resource usage problem may be more difficult here, attaching profilers or debuggers little difficult. furthermore, the environment in which the code runs is typically not open source so its performance characteristics cannot be precisely replicated in the local environment.

Serverless Frameworks

AWS Lambda, Azure functions with node.js, Kubernetes etc.

Swift | iOS 10 | Orientation | Quick Notes

When it comes to handling Orientation in iOS App Development, creates little confusion because with every release their minor changes. so let’s see who does it works with iOS 10.

First thing if you want to support all Orientations just enable it from here.

Screen Shot 2017-08-02 at 3.40.51 PM.png

Second, if the requirement is something like, need Orientation support only for few Controllers. make sure you have followed the first case and just this code snippet for enabling/disable it for each view.

override var shouldAutorotate: Bool {
    return true
}

its simple as its looking just return `true` if you want to support orientation for controller else return `false`. Next concern is if you are returning true then you have an option to specify the orientations as well just implement this code snippet.

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.all
} 

Click `UIInterfaceOrientationMask` to see the options so just return whatever you want to use. Sounds good?

public struct UIInterfaceOrientationMask : OptionSet {
    public init(rawValue: UInt)
    public static var portrait: UIInterfaceOrientationMask { get }
    public static var landscapeLeft: UIInterfaceOrientationMask { get }
    public static var landscapeRight: UIInterfaceOrientationMask { get }
    public static var portraitUpsideDown: UIInterfaceOrientationMask { get }
    public static var landscape: UIInterfaceOrientationMask { get }
    public static var all: UIInterfaceOrientationMask { get }
    public static var allButUpsideDown: UIInterfaceOrientationMask { get }
}

Thank you for reading.

Make your iOS apps more secure with SSL pinning

SSL/Certificate pinning plays a very critical role in building highly secure mobile apps which users will be able to use even in countless insecure wireless network connections.

At a glance, Idea is the SSL(Secure Socket Layer) ensures the encrypted client-server communication over HTTPS. The encryption is based on PKI (Public Key Infrastructure) and a session key. The session key was introduced because encrypting and decrypting a public/private key uses a lot of processing time/power/space for sure it will slow down the process.

MIMT, Yes SSL Communication is very secure but the man-in-the-middle attack still poses an exact threat using ARP cache poisoning and DNS spoofing.

SSL/Certificate Pinning, ensure that the app communicates only with the designated server only and the prerequisites for SSL pinning is saving the target’s server SSL certificate within the app bundle.

SSL pinning is implemented within the

    func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void

and here are the steps we need to follow.

  • First read the server trust and server certificate.

let serverTrust = challenge.protectionSpace.serverTrust
let certificate = SecTrustGetCertificateAtIndex(serverTrust, 0

  • Now set the policies for server validation, previous failure count etc.

SecTrustSetPolicies(serverTrust, SecPolicyCreateSSL(true, (challenge.protectionSpace.host as CFString)))

  • Start policies validation, convert server certificate in Data and get the local certificate from bundle.

 let remoteCertificateData = SecCertificateCopyData(certificate)
 let pathToCert = Bundle.main.path(forResource: “certificate”, ofType: “cer”

At last compare your policies result and local certificate data with your server certificate data, if everything goes well complete the challange with credentail.

completionHandler(.UseCredential, credential)

Otherwise cancel the authentication and pass nil as credentails.

completionHandler(.CancelAuthenticationChallenge, nil)

Thank you reading, you can download the source code from GIT and also learn contribute about iOS Security.

Developing Secure iOS Apps | iOS | Swift

Yesterday I gave a session about `Developing Secure iOS Apps` @GoJek Bangalore, Thanks to Swift Developer Group.

The reason why I have discussed this topic is that because secure coding is the practice of writing programs that are resistant to attack by malicious or mischievous people or programs. Secure coding helps protect a user’s data from theft or corruption.

For helping the community we need the day to day support from everyone, please feel free to post whatever you are learning day to day.

I have posted code base on GIT and slides are at SlideShare.net

Please feel free to share your comments.

Happy Learning!

Creating and distributing iOS frameworks | Swift | Quick Notes

Do you want to share your code with other apps or may be other developers or perhaps you want to distribute your code in the same way as popular 3rd parties do?

Frameworks have three major purposes.

  • Encapsulation of Code
  • Modularity of Code
  • Reusability of Code

Open Xcode, select Cocoa Touch Framework, give meta data about your framework, Just drag and drop the files you want to add and here we going just build it and share the framework with other developers etc.

framework

Points need to take care

  1. Access control, Swift has three level of access control. Just follow when creating your own framework.
    1. Public, code called by other framework or the app.
    2. Internal, code called within the framework.
    3. Fileprivate, the code called within a single file.
    4. Private, code called within a single class, even it won’t be visible in extension of the class
  2. Sometimes when you integrate framework it gives a crash while launching “framework not found” then simply clean or restart the Xcode works.
  3. If you want to include the storyboard within the framework then make sure you are accessing it using Bundle with an identifier.
  4. Once build your framework generates file Framework-Swift.h (Framework/Headers/Framework-Swift.h) where you can see who all files will be publicly available to use.

  5. Enable the check `Always Embed Swift Standard Libraries` will give you the flexibility to use it with lower Swift versions.

  6. For best practice, add framework target within your working copy of the code, whenever wants to release just change the target and create the new framework.

    Thanks for Reading!!!

Make greatest impact for yourself ?

Introduce priorities, they are areas of focus where you make the greatest impact to achieve your best. Priorities will help you to focus on what is more important, how to organize and where to spend the energy.

Priorities are anything that you needs to be top of mind, they are dynamic means you are adding something, checking progress and then adjusting them.

So define what exactly we want to do, make a list and start working on it. Few things that really matter.

  1. Do what you can with what you have.
  2. Small things matter
  3. Something amazing
  4. Fight for someone rights
  5. Patience and go to the distance

Thanks for reading.

Focus on yourself | Quick Note

What will happen when we think about what is right with the people rather than what wrong with them?

There is three principal of strength-based development.

  1. The way in which you naturally think, behave or feel show your power and the potential.
  2.  Become the best, increase your understanding of your potential so you can develop.
  3.  Maximum productivity, gain by focusing on your potential and managing your weaknesses.

Exercise is write down “I use my strength every day” once with your dominant hand and then with the nondominant hand.

Completed ? now realize how did it feel? how much longer was it? Although you were able to complete but, it was a struggle.

There is a book called, The Clifton Strength Finder. A 30-minute survey that will identify your talents and find a common language to use and to support your strength-based approach.

Talk About it -> Name it -> Claim it -> Aim it.