TDSWSSecurity.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // TDSWSSecurity.h
  4. //
  5. // Created by Austin and Dalton Cherry on on 9/3/15.
  6. // Copyright (c) 2014-2017 Austin Cherry.
  7. //
  8. // Licensed under the Apache License, Version 2.0 (the "License");
  9. // you may not use this file except in compliance with the License.
  10. // You may obtain a copy of the License at
  11. //
  12. // http://www.apache.org/licenses/LICENSE-2.0
  13. //
  14. // Unless required by applicable law or agreed to in writing, software
  15. // distributed under the License is distributed on an "AS IS" BASIS,
  16. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. // See the License for the specific language governing permissions and
  18. // limitations under the License.
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////////////////////
  21. #import <Foundation/Foundation.h>
  22. #import <Security/Security.h>
  23. @interface TDSWSSSLCert : NSObject
  24. /**
  25. Designated init for certificates
  26. :param: data is the binary data of the certificate
  27. :returns: a representation security object to be used with
  28. */
  29. - (instancetype)initWithData:(NSData *)data;
  30. /**
  31. Designated init for public keys
  32. :param: key is the public key to be used
  33. :returns: a representation security object to be used with
  34. */
  35. - (instancetype)initWithKey:(SecKeyRef)key;
  36. @end
  37. @interface TDSWSSecurity : NSObject
  38. /**
  39. Use certs from main app bundle
  40. :param usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
  41. :returns: a representation security object to be used with
  42. */
  43. - (instancetype)initWithCerts:(NSArray<TDSWSSSLCert*>*)certs publicKeys:(BOOL)publicKeys;
  44. /**
  45. Designated init
  46. :param keys: is the certificates or public keys to use
  47. :param usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
  48. :returns: a representation security object to be used with
  49. */
  50. - (instancetype)initUsingPublicKeys:(BOOL)publicKeys;
  51. /**
  52. Should the domain name be validated? Default is YES.
  53. */
  54. @property(nonatomic)BOOL validatedDN;
  55. /**
  56. Validate if the cert is legit or not.
  57. :param: trust is the trust to validate
  58. :param: domain to validate along with the trust (can be nil)
  59. :return: YES or NO if valid.
  60. */
  61. - (BOOL)isValid:(SecTrustRef)trust domain:(NSString*)domain;
  62. @end