Reputation: 449
I want to encode p7b file with certificate chain to pem
I can do it in console with openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
I want to do it with erlang ssl library - looks like otp should already do this without asn.1 test in erlang otp
But
1> application:ensure_all_started(ssl).
{ok,[crypto,asn1,public_key,ssl]}
But PKCS7
module undefined - asn.1 was not compiled
2> 'PKCS7':decode('SignedData', Der1).
** exception error: undefined function 'PKCS7':decode/2
If I download PKCS7.asn manually and try to compile, I'll get error
3> asn1ct:compile('PKCS7.asn')
PKCS7:13: 'Attribute' is not exported from InformationFramework
...
{error,[{structured_error,{'PKCS7',13},
asn1ct_check,
{undefined_import,'Attribute','InformationFramework'}},
{structured_error,{'PKCS7',13},
Question 1: Is there any way to compile 'PKCS7' without manual downloading asn.1 modules? I am sure I missed something important, and this file should works automatically as otp lib
Question 2: Maybe there are some simplest way to encode p7b to pem chain?
Is there any documentation for using otp/lib/asn.1?
Upvotes: 1
Views: 314
Reputation: 449
There are no need to compile ANS.1 module PKCS7. The Erlang (Elixir) function public_key:der_decode/2
works with 'ContentInfo'
atom as the first argument ASN1Type.
(elixir code)
{:ContentInfo, _id, content_info} = :public_key.der_decode(:ContentInfo, p7b_binary)
{:certSet, certificates_set} = elem(content_info, 4)
But question why 'PKCS7':decode
does not works still open
Upvotes: 2