andrewcbancroft / SwiftyLocalReceiptValidator

An implementation of local receipt validation logic for iOS in Swift
MIT License
286 stars 32 forks source link

Not compiling with OpenSSL 1.0.210 #2

Closed PaulWagener closed 7 years ago

PaulWagener commented 7 years ago

I'm currently working on a SwiftyStorekit project and want to integrate SwiftyLocalReceiptValidator for offline checking of the receipt (so also waiting for the result of issue #1 ).

When following the instructions written at https://www.andrewcbancroft.com/2015/09/21/openssl-for-ios-swift-the-easy-way/ with OpenSSL 1.0.210, Swift 4 and Xcode 9 I seem to hit a few new roadblocks. There are a lot of undeclared references, I've managed to solve most of them by including a few extra headers in the bridging header:

#import <openssl/sha.h>
#import <openssl/x509.h>

But that still leaves one undeclared reference: the pkcs7_d_sign () function at https://github.com/andrewcbancroft/SwiftyLocalReceiptValidator/blob/master/ReceiptValidator.swift#L174

I can't seem to find any mention of this function in the OpenSSL headers, and when searching online I only get references to Swift receipt validation. My guess is that this function was removed in the last two years, could you help me with a workaround?

andrewcbancroft commented 7 years ago

Thank you for reporting this, Paul!

I'm going to start looking into this soon (I'm super slow these days, just bogged down with [insert life event here], haha). But I do want this to work with Swift 4, so I intend to explore a bit more.

The info you provided gives me a few ideas - if you discover anything additional that might help me or others solve this one, feel free to continue the dialogue!

PaulWagener commented 7 years ago

Ok, I've figured out a way. It turns out that a step that is on your blog (but not in this repository) is mandatory for it to compile. I included the two files pkcs7_union_accessors.h and pkcs7_union_accessors.c that are described here. And included them in the bridging header:

#include "pkcs7_union_accessors.h"
#import <openssl/pkcs7.h>
#import <openssl/objects.h>
#import <openssl/sha.h>
#import <openssl/x509.h>

After those steps the whole project compiles and works as advertised.

andrewcbancroft commented 7 years ago

Oh my goodness. I'm so sorry -- I'm going to add the bridging header to the repo and document that a little better.

When I wrote the series, there was literally a year between when I started and when I finished, so I had just forgotten about the bridging header requirement.

markst commented 5 years ago

Sorry to raise an old issue. But is there a way this can be resolved without statically-linking OpenSSL? https://github.com/IBM-Swift/OpenSSL