7

I am learning how to add in-app purchase receipt validation to my iOS/OSX projects.

There is a nice overview here and the WWDC14 has good videos on this topic.

Plenty of sample code, but everyone skips one step. How to import the openSSL header. The swift compiler complains that there is no such module.

import Foundation
import StoreKit
import openssl  //no such module ???

I am already stuck before writing one line of code. Where is the openssl framework hiding?

Community
  • 1
  • 1
user965972
  • 2,489
  • 2
  • 23
  • 39
  • Check out my answer over here, seems to do the trick: https://stackoverflow.com/a/61804357/2622870 – 2075 May 14 '20 at 18:10

1 Answers1

4

There is no OpenSSL module built in. You have to compile it yourself - this is for security so that everyone doesn't implement the exact same security.

Take a look at : https://gist.github.com/foozmeat/5154962 http://www.cvursache.com/2013/08/13/How-To-Build-openssl-For-iOS/

There is a also a cocoapods at http://cocoapods.org/?q=openssl

You should never use a static module provided by someone else. Always build your own.

Apples official explanation here - under OpenSSl - https://developer.apple.com/library/ios/documentation/Security/Conceptual/cryptoservices/GeneralPurposeCrypto/GeneralPurposeCrypto.html

Dave Roberts
  • 672
  • 3
  • 9
  • This script worked for me. https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh – user965972 Jul 13 '15 at 16:24
  • I am facing problem in configured openssl in swift project. Please suggest it , How to configured openssl in swift. – Vipulk617 Oct 14 '15 at 06:13
  • @user965972 can you send demo application openssl with swift. – Vipulk617 Oct 14 '15 at 12:43
  • @vipulk617 No, sorry. I learned that the reason there is no standard module is due to security reasons. Everyone should make their own module to reduce the risk of a security breach. Just look at what Dave posted. You can use that to figure out how to build you own. – user965972 Oct 15 '15 at 11:20
  • @user965972 I just want to access private content from cloud front using following link https://forums.aws.amazon.com/thread.jspa?messageID=336955 But not able to use openssl in swift . I just want to know , How to only integrate openssl library in swift not write any code because i tried this library in swift but getting error. – Vipulk617 Oct 15 '15 at 11:41
  • Download the openssl source, compile it (there are scripts available for iOS/OSX), include the compiled code as a framework into your xcode project. – user965972 Oct 15 '15 at 11:48
  • I am using cocoa pod for openssl but getting error when i write #include in header file. This error is only swift project . – Vipulk617 Oct 15 '15 at 12:29