Subject: | Work around for Digest::MD5 wide character issues |
Date: | Fri, 3 Jan 2014 11:31:10 -0800 |
To: | bug-Net-OpenSRS [...] rt.cpan.org |
From: | Marco Palma <marco.palma [...] openx.com> |
Using developer release 0.07_01 on perl 5.10, I have run into an issue in
the make_request method at line 923, where the user agent posts to the API
service. At least one of our Certificate Signing Requests is seen as utf8
and triggers an error from inside Digest::MD5's md5_hex function that
returns "Wide character in subroutine entry".
I came upon this related RT bug:
https://rt.cpan.org/Public/Bug/Display.html?id=83029 in which the final
response states that "This is not a bug" and suggests that the work around
is to encode the $xml content as utf8 prior to submitting this text to
md5_hex.
So my patch amounts to:
--- OpenSRS.pm-stock0.07_01.pm 2014-01-03 19:14:20.000000000 +0000
+++ OpenSRS.pm-stock0.07_01-patched.pm 2014-01-03 19:26:14.000000000 +0000
@@ -147,6 +147,7 @@
use warnings;
use LWP::UserAgent;
use XML::Simple;
+use Encode qw(encode_utf8);
use Digest::MD5;
use Date::Calc qw/ Add_Delta_Days Today This_Year /;
@@ -920,11 +921,12 @@
return undef;
}
+ my $encoded = encode_utf8($xml);
my $res = $ua->post(
$host,
'Content-Type' => 'text/xml',
'X-Username' => $self->{config}->{username},
- 'X-Signature' => hash( hash( $xml, $key ), $key ),
+ 'X-Signature' => hash( hash( $encoded, $key ), $key ),
'Content' => $xml
);
I have test this against the Horizon testing service with a CSR which did
not trigger the utf8 issue and with the one that did and both post
successfully now.
Message body not shown because it is not plain text.