TSKTrustDecision.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. TSKTrustDecision.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. #if __has_feature(modules)
  9. @import Foundation;
  10. #else
  11. #import <Foundation/Foundation.h>
  12. #endif
  13. /**
  14. Possible return values when verifying a server's identity against a set of pins.
  15. */
  16. typedef NS_ENUM(NSInteger, TSKTrustEvaluationResult)
  17. {
  18. /**
  19. The server trust was succesfully evaluated and contained at least one of the configured pins.
  20. */
  21. TSKTrustEvaluationSuccess,
  22. /**
  23. The server trust was succesfully evaluated but did not contain any of the configured pins.
  24. */
  25. TSKTrustEvaluationFailedNoMatchingPin,
  26. /**
  27. The server trust's evaluation failed: the server's certificate chain is not trusted.
  28. */
  29. TSKTrustEvaluationFailedInvalidCertificateChain,
  30. /**
  31. The server trust could not be evaluated due to invalid parameters.
  32. */
  33. TSKTrustEvaluationErrorInvalidParameters,
  34. /**
  35. The server trust was succesfully evaluated but did not contain any of the configured pins. However, the certificate chain terminates at a user-defined trust anchor (ie. a custom/private CA that was manually added to the macOS trust store). Only available on macOS.
  36. */
  37. TSKTrustEvaluationFailedUserDefinedTrustAnchor NS_AVAILABLE_MAC(10_9),
  38. /**
  39. The server trust could not be evaluated due to an error when trying to generate the certificate's subject public key info hash. On iOS 9 or below, this could be caused by a Keychain failure when trying to extract the certificate's public key bytes.
  40. */
  41. TSKTrustEvaluationErrorCouldNotGenerateSpkiHash,
  42. };
  43. /**
  44. Possible return values when verifying a server's identity against an SSL pinning policy.
  45. */
  46. typedef NS_ENUM(NSInteger, TSKTrustDecision)
  47. {
  48. /**
  49. Based on the server's certificate chain and the configured pinning policy for this domain, the SSL connection should be allowed.
  50. This return value does not necessarily mean that the pinning validation succeded (for example if `kTSKEnforcePinning` was set to `NO` for this domain). If a pinning validation failure occured and if a report URI was configured, a pin failure report was sent.
  51. */
  52. TSKTrustDecisionShouldAllowConnection,
  53. /**
  54. Based on the server's certificate chain and the configured pinning policy for this domain, the SSL connection should be blocked.
  55. A pinning validation failure occured and if a report URI was configured, a pin failure report was sent.
  56. */
  57. TSKTrustDecisionShouldBlockConnection,
  58. /**
  59. No pinning policy was configured for this domain and TrustKit did not validate the server's identity.
  60. Because this will happen in an authentication handler, it means that the server's _serverTrust_ object __needs__ to be verified against the device's trust store using `SecTrustEvaluate()`. Failing to do so will __disable SSL certificate validation__.
  61. */
  62. TSKTrustDecisionDomainNotPinned,
  63. };