|
Line 0
Link Here
|
|
|
1 |
Source: https://github.com/potatosalad/erlang-jose/commit/833f81666a0f9fc31e7a3c2403d72e168a4a3209.patch |
| 2 |
|
| 3 |
--- deps/jose/src/jose_server.erl.orig 2018-12-31 15:47:40 UTC |
| 4 |
+++ deps/jose/src/jose_server.erl |
| 5 |
@@ -162,9 +162,7 @@ support_check() -> |
| 6 |
|
| 7 |
%% @private |
| 8 |
check_ec_key_mode(_Fallback, Entries) -> |
| 9 |
- ECPEMEntry = { |
| 10 |
- 'ECPrivateKey', |
| 11 |
- << |
| 12 |
+ PEMBin = << |
| 13 |
48,119,2,1,1,4,32,104,152,88,12,19,82,251,156,171,31,222,207, |
| 14 |
0,76,115,88,210,229,36,106,137,192,81,153,154,254,226,38,247, |
| 15 |
70,226,157,160,10,6,8,42,134,72,206,61,3,1,7,161,68,3,66,0,4, |
| 16 |
@@ -173,13 +171,23 @@ check_ec_key_mode(_Fallback, Entries) -> |
| 17 |
36,225,0,90,21,186,235,132,152,229,13,189,196,121,64,84,64, |
| 18 |
229,173,12,24,23,127,175,67,247,29,139,91 |
| 19 |
>>, |
| 20 |
- not_encrypted |
| 21 |
- }, |
| 22 |
- case public_key:pem_entry_decode(ECPEMEntry) of |
| 23 |
- #'ECPrivateKey'{ privateKey = PrivateKey, publicKey = PublicKey } when is_list(PrivateKey) andalso is_tuple(PublicKey) -> |
| 24 |
- [{ec_key_mode, list} | Entries]; |
| 25 |
- #'ECPrivateKey'{ privateKey = PrivateKey, publicKey = PublicKey } when is_binary(PrivateKey) andalso is_binary(PublicKey) -> |
| 26 |
- [{ec_key_mode, binary} | Entries] |
| 27 |
+ PEMEntry = {'ECPrivateKey', PEMBin, not_encrypted}, |
| 28 |
+ %% Erlang 24 changes 'ECPrivateKey' record in a way that makes record matching fail |
| 29 |
+ %% when this module is compiled on Erlang 23 (or earlier) but runs on 24. |
| 30 |
+ %% So we destructure tuples, as ugly as it may be. |
| 31 |
+ %% |
| 32 |
+ %% See erlang-jose#113 for details. |
| 33 |
+ PrivateKey = case list_to_integer(erlang:system_info(otp_release)) >= 24 of |
| 34 |
+ true -> |
| 35 |
+ {'ECPrivateKey', _Version, PrivKey0, _Params, _PubKey0, _Attributes} = public_key:pem_entry_decode(PEMEntry), |
| 36 |
+ PrivKey0; |
| 37 |
+ false -> |
| 38 |
+ {'ECPrivateKey', _Version, PrivKey0, _Params, _PubKey0} = public_key:pem_entry_decode(PEMEntry), |
| 39 |
+ PrivKey0 |
| 40 |
+ end, |
| 41 |
+ case is_binary(PrivateKey) of |
| 42 |
+ true -> [{ec_key_mode, binary} | Entries]; |
| 43 |
+ _ -> [{ec_key_mode, list} | Entries] |
| 44 |
end. |
| 45 |
|
| 46 |
%% @private |