Skip to content

Commit

Permalink
RSA+DSA+ECC export_key_jwk produces canonical JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
karel-m committed Apr 25, 2016
1 parent 3a53c9e commit 33a6c68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TODO:
0.031 2016/04/XX
- RSA+DSA public key export now produces PEM/DER compatible with openssl
public keys exported be previous version can still be imported
- RSA+DSA+ECC export_key_jwk produces canonical JSON

0.030 2016/04/13
- fix: 0.029 + 0.028 by mistake installed *.inc files to perl/(lib|site|vendor)
Expand Down
7 changes: 6 additions & 1 deletion lib/CryptX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ sub _decode_json {

sub _encode_json {
croak "FATAL: cannot find JSON::PP or JSON::XS or Cpanel::JSON::XS" if !$has_json;
encode_json(shift);
my $data = shift;
my $rv = encode_json($data); # non-canonical fallback
return(eval { Cpanel::JSON::XS->new->canonical->encode($data) } || $rv) if $has_json == 1;
return(eval { JSON::XS->new->canonical->encode($data) } || $rv) if $has_json == 2;
return(eval { JSON::PP->new->canonical->encode($data) } || $rv) if $has_json == 3;
return($rv);
}

1;
Expand Down

1 comment on commit 33a6c68

@FGasper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! :)

Please sign in to comment.