Skip to content

A wrapper around NSURLSession providing validation of server certificates and easy-to-use client certificate authentication.

License

Notifications You must be signed in to change notification settings

northpolesec/macops-MOLAuthenticatingURLSession

 
 

Repository files navigation

MOLAuthenticatingURLSession

A wrapper around NSURLSession providing validation of server certificates and easy-to-use client certificate authentication.

Requires ARC. Tested on OS X 10.11+.

Usage

#import <MOLAuthenticatingURLSession/MOLAuthenticatingURLSession.h>

- (void)postToServer {
  MOLAuthenticatingURLSession *authURLSession = [[MOLAuthenticatingURLSession alloc] init];
  authURLSession.userAgent = @"MyUserAgent";
  authURLSession.refusesRedirects = YES;
  authURLSession.serverHostname = @"my-hostname.com";
  NSURLSession *session = authURLSession.session;
  // You can use the NSURLSession as you would normally..
}

If you'd like to print status/error information:

  authURLSession.loggingBlock = ^(NSString *line) {
    NSLog(@"%@", line);
  };

Installation

Using Bazel Modules

Add the following to your MODULE.bazel:

bazel_dep("molauthenticatingurlsession", version = "3.1")
git_override(
    module_name = "molauthenticatingurlsession",
    remote = "https://github.com/google/macops-molauthenticatingurlsession.git",
    tag = "v3.1",
)

Using Bazel WORKSPACE

Add the following to your WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

# Needed for MOLAuthenticatingURLSession
git_repository(
    name = "molcertificate",
    remote = "https://github.com/google/macops-molcertificate.git",
    tag = "v2.0",
)

git_repository(
    name = "molauthenticatingurlsession",
    remote = "https://github.com/google/macops-molauthenticatingurlsession.git",
    tag = "v2.5",
)

Adding dependency in BUILD

In your BUILD file, add MOLAuthenticatingURLSession as a dependency:

objc_library(
    name = "MyAwesomeApp_lib",
    srcs = ["src/MyAwesomeApp.m", "src/MyAwesomeApp.h"],
    deps = ["@molauthenticatingurlsession//:MOLAuthenticatingURLSession"],
)

Contributing

Patches to this library are very much welcome. Please see the CONTRIBUTING file.

About

A wrapper around NSURLSession providing validation of server certificates and easy-to-use client certificate authentication.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 95.5%
  • Starlark 4.5%