TSKBackgroundReporter.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. TSKBackgroundReporter.h
  3. TrustKit
  4. Copyright 2015 The TrustKit Project Authors
  5. Licensed under the MIT license, see associated LICENSE file for terms.
  6. See AUTHORS file for the list of project authors.
  7. */
  8. #import "../Pinning/ssl_pin_verifier.h"
  9. #if __has_feature(modules)
  10. @import Foundation;
  11. #else
  12. #import <Foundation/Foundation.h>
  13. #endif
  14. /**
  15. `TSKSimpleBackgroundReporter` is a class for uploading pin failure reports using the background transfer service.
  16. */
  17. @interface TSKBackgroundReporter : NSObject <NSURLSessionTaskDelegate>
  18. ///---------------------
  19. /// @name Initialization
  20. ///---------------------
  21. /**
  22. Initializes a background reporter.
  23. @param shouldRateLimitReports Prevent identical pin failure reports from being sent more than once per day.
  24. @param sharedContainerIdentifier The container identifier for an app extension. This must be set in order
  25. for reports to be sent from an app extension. See
  26. https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1409450-sharedcontaineridentifier
  27. @exception NSException Thrown when the App does not have a bundle ID, meaning we're running in unit tests where the background transfer service can't be used.
  28. */
  29. - (nonnull instancetype)initAndRateLimitReports:(BOOL)shouldRateLimitReports
  30. sharedContainerIdentifier:(nullable NSString *)sharedContainerIdentifier;
  31. ///----------------------
  32. /// @name Sending Reports
  33. ///----------------------
  34. /**
  35. Send a pin validation failure report; each argument is described section 3. of RFC 7469.
  36. */
  37. - (void)pinValidationFailedForHostname:(nonnull NSString *)serverHostname
  38. port:(nullable NSNumber *)serverPort
  39. certificateChain:(nonnull NSArray *)certificateChain
  40. notedHostname:(nonnull NSString *)notedHostname
  41. reportURIs:(nonnull NSArray<NSURL *> *)reportURIs
  42. includeSubdomains:(BOOL)includeSubdomains
  43. enforcePinning:(BOOL)enforcePinning
  44. knownPins:(nonnull NSSet<NSData *> *)knownPins
  45. validationResult:(TSKTrustEvaluationResult)validationResult
  46. expirationDate:(nullable NSDate *)knownPinsExpirationDate;
  47. - (void)URLSession:(nonnull NSURLSession *)session task:(nonnull NSURLSessionTask *)task didCompleteWithError:(nullable NSError *)error;
  48. @end