ASN.1 API is deprecated, is there any replacement?

Hi, I would need to encode my data in ASN.1 Looking at the API, it is marked as deprecated, the API reference has been removed. Is there any alternative?

Thanks

Replies

Looking at the API, it is marked as deprecated

Indeed. Although do note that this was only every available on the Mac.

Is there any alternative?

Not from Apple )-:

There are a variety of open source ASN.1 libraries that you might use. I haven’t researched this in depth, so I don’t have a specific recommendation.

What are you doing with ASN.1? It’s possible that there might be an alternative path forward that doesn’t need a full-blown ASN.1 library.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the quick answer. I aim to store a digital signature inside a PDF, and according to Adobe's documentation the signature object should be encoded in DER format. (So ASN.1 was fitting for that purpose).

Just to be sure before investigating any 3rd party:

  • Do you have in mind any other Mac libraries that could fit?
  • The ASN.1 looks available until MacOS 12.0, does Apple have a plan to remove it in future versions?

Do you have in mind any other Mac libraries that could fit?

No, sorry [1].

The ASN.1 looks available until MacOS 12.0, does Apple have a plan to remove it in future versions?

I can’t comment on The Future™. My experience, however, is that:

  • Apple rarely removes APIs from the system, even deprecated ones.

  • It is, however, common for us to remove long-deprecated APIs from the headers, which makes using them a hassle.

  • Deprecated APIs don’t get a lot of maintenance.

  • Deprecated APIs most often go away on platform or architecture changes. For example, SecAsn1Coder is not available on iOS, so you’d need to find an alternative if you ported your app to iOS.

I aim to store a digital signature inside a PDF, and according to Adobe's documentation the signature object should be encoded in DER format.

Can you post more details? In a simple case like this you can often get away with building the DER structure by hand based on a hard-wired template.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I have my own code for ASN.1 parsing and rendering but I can’t share that. And I wrote my own code because, working in DTS, I’m not able to depend on third-party libraries, and that’s also why I’m have no relevant experience in this space.

I won't need to go further in details as I finally found that Apple's CMS API was the right answer. :) I know it is definitely not a DER encoder but was fitting to generate a cryptographic message in the format support by PDF
Thank you again for your help !

Yeah, CMSEncoder is cool, and it makes sense to use the highest level API that meets your needs.

It is annoying that CMSEncoder and CMSDecoder are not available on iOS. If you think you might need this support on iOS some day, I encourage you to file an enhancement request for that.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Another important use of ASN is (was) parsing of appstore receipts. Any recommended replacement for that functionality?

Another important use of ASN is (was) parsing of appstore receipts.

Receipt validation isn’t really my bailiwick but I was under the impression that StoreKit 2 changes the landscape completely. See WWDC 2021 Session 10114 Meet StoreKit 2.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"