Coder Social home page Coder Social logo

mtls's Introduction

Mutual TLS Authentication(mTLS) - Swift

This demo demonstrates how to implement mutual TLS authentication (mTLS) in Swift. mTLS is a security mechanism that allows both the client and server to authenticate each other using their own digital certificates. This is in contrast to traditional TLS, where only the server authenticates itself to the client.

Instructions

  1. Create a PKCS12 file containing your client certificate and key.
  2. Add the PKCS12 file to your project.
  3. Update the certificateFileName and password variables in the AppDelegate class to match your PKCS12 file.
  4. Run the app.

Example Usage

To perform a request using the manually configured TLS session, simply use the URLSessionMTLS.shared object:

let session = URLSessionMTLS.shared

// Create a request to the server
let request = URLRequest(url: URL(string: "https://example.com/api")!)

// Send the request
session.dataTask(with: request) { data, response, error in
  // Handle the response
}.resume()

Note: You must add a .p12 certificate file to your project and update the certificateFileName and password variables in the AppDelegate class before running the app.

References

License

This demo is licensed under the MIT License.

mtls's People

Contributors

pansuriyaravi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.