Hi I am a newbie to perl. How to create a pkcs7 signature in perl .Any Example code would be helpful. I tried to use OpenCA::OpenSSL. I got error initializing OpenCA::OpenSSL instance.
Thanks in Advance.......
My code
$openssl = OpenCA::OpenSSL->new(path=>'/usr/bin/openssl');
my $crl=$openssl->issueCrl(
CAKEY=>'passbook/key.pem',
CACERT=>'passbook/certificate.pem',
PASSWD=>'somepass',
OUTFILE=>'passbook/signature',
OUTFORM=>'DER',
);
The error message i got was
Use of uninitialized value $initial_skip in concatenation (.) or string at
/usr/local/share/perl/5.14.2/Parse/RecDescent.pm line 3054."
Related
I am trying to configure the environment for OpenDDS, but I could not run the configure script. Would really appreciate much, if there are any insight from you guys. =D
So basically, after I download the OpenDDS-3.12.zip from here. I have extracted to a folder and tried to run the configure file with this command in VS command prompt (VS2017)
configure --compiler=gcc
Next, the "ACE+TAO-2.2a_with_latest_patches_NO_makefiles" is downloaded and I extract the zip file to the root folder.
Then it shows this message.
ACE_ROOT/ace/config.h exists, skipping configuration of ACE+TAO
Use of uninitialized value $mpctype in string eq at configure line 1103.
Use of uninitialized value $mpctype in concatenation (.) or string at configure line 1257.
Use of uninitialized value $mpctype in string eq at configure line 1266.
Running MPC to generate project files.
MPC_ROOT was set to C:\src\OpenDDS-DDS-3.12.2\ACE_wrappers\MPC.
Using .../OpenDDS-DDS-
3.12.2/ACE_wrappers/bin/MakeProjectCreator/config/MPC.cfg
ERROR: Invalid type: C:\src\OpenDDS-DDS-3.12.2\DDS_TAOv2_all.mwc
mwc.pl v4.1.28
...
/*lots of explanation of each file here*
*then followed by*/
...
ERROR: Error from MPC, stopped at configure line 1270.
I have both Visual Studio 2017 and Perl 5.22 installed as well, I am not sure whether if this is a compiler issue or any other issue. The following is the configure script that printed the error above.
## line 1268 -- 1270 ##
if (!$opts{'dry-run'}) {
if (system("perl \"$ENV{'ACE_ROOT'}/bin/mwc.pl\" $mwcargs") != 0) {
die "ERROR: Error from MPC, stopped";
}
}
$mpctype is defined here:
my $mpctype = ($slash eq '/' ||
($cross_compile && $buildEnv->{'build'} eq 'target'))
? 'gnuace' : $opts{'compiler_version'};
It seems to be looking at $opts{'compiler_version'}, which is apparently empty. %opts is defined here:
my %opts = %{parseArgs()};
so it looks like you should define the compiler_version in the command line or define the target platform. It's probably better if you check out the INSTALL options thoroughly
VS2017 doesn't install c++ compiler by default.
Modify VS 2017 and select c++ compiler and install if VS 2017 already install.
configure (without --compiler=gcc flag)
I had a similar question. Being a newbie, I started with the getting started with java and windows on https://opendds.org/quickstart/GettingStartedWindows.html .
Step 5, "configure (To enable Java support, use configure --java)" didn't work in a visual studio command window despite
having set JAVA_HOME. I had sent ACE_ROOT, DDS_ROOT, TAO_ROOT and MPC_ROOT though the tutorial didn't specify based on trying to debug this problem.
When using the "--compiler" option I get errors similar to the ones in this thread. Was there any resolution just to get the"
"off-the-shelf" tutorial working. Using Windows 10.
D:\data\OpenDDS-3.13.3>configure --java --compiler="C:\Program Files\Java\jdk1.8.0_221\bin"
ACE_ROOT/ace/config.h exists, skipping configuration of ACE+TAO
Use of uninitialized value $mpctype in string eq at configure line 1482.
Use of uninitialized value $mpctype in concatenation (.) or string at configure line
1646.
Use of uninitialized value $mpctype in string eq at configure line 1655.
Running MPC to generate project files.
MPC_ROOT was set to D:\data\OpenDDS-3.13.3\ACE_WRAPPERS\MPC.
Using .../OpenDDS-3.13.3/ACE_WRAPPERS/bin/MakeProjectCreator/config/MPC.cfg
ERROR: Invalid type: D:\data\OpenDDS-3.13.3\DDS_TAOv2_all.mwc
mwc.pl v4.1.44
...
ERROR: Error from MPC, stopped at configure line 1659.
I am trying to sign my data using Crypt::OpenSSL::RSA in perl. This is my code
use Crypt::OpenSSL::RSA;
open $privfh, '>:encoding(UTF-8)', 'private_key';
$rsa = Crypt::OpenSSL::RSA->generate_key(1024);
$key_string=$rsa->get_private_key_string();
print $privfh $key_string;
$rsa_priv = Crypt::OpenSSL::RSA->new_private_key($key_string);
$rsa_pub = $rsa->get_public_key_string();
$plaintext="hello";
$signature = $rsa_priv->sign($plaintext);
print "Signed correctly\n" if ($rsa->verify($plaintext, $signature));
This program is running fine and i am able to sign data correctly. But the issue is that i have to sign a lot of data so i am writing key_string to a file so that i can use it again and again but the issue is when i try to use it again using following code
use Crypt::OpenSSL::RSA;
open FILE ,'<','private_key';
{
local $/;
$keystring=<FILE>;
}
print "$keystring\n";
$rsa_priv = Crypt::OpenSSL::RSA->new_private_key($key_string);
it is throwing error and not generating $rsa_priv. The error given by the program is
RSA.xs:178: OpenSSL error: no start line at testperl.pl line 11, <FILE> line 1.
What should i do so that i am able to signing again and again after generating key for one time only.
You are reading the file into a variable $keystring but initializing the private key using the variable $key_string. Change $keystring to $key_string.
Perl offers use strict; to avoid these kind of problems.
Also, if you use use warnings;, perl will also warn you about accessing unitialized variables.
I was testing the functionality of PDF::Tk by installing in cpan module and installed the pdftk binary file and the path to variable and tried running source code.
source code:
use PDF::Tk;
my $doc = PDF::Tk->new( pdftk => '/apps/free/pdftk/' );
$doc->call_pdftk( 'input.pdf', 'outPDF.pdf', 'cat', '1-14' );
getting error as below:
pdftk input.pdf cat 1-14 releasenote.pdf failed: -1 at
/usr/lib/perl5/site_perl/5.10.0/PDF/Tk.pm line 73.
please guide me in resolving it.
Seems you are passing the wrong argument to the constructor of PDF::Tk. Have a look here.
You're supposed to pass a hash, with the key pdftk, and this should be the path of the executable, not a directory. As you can see here, this will be executed via system, so of course, executing a directory does not work.
To clarify, you should be using:
my $doc=PDF::Tk->new(pdftk => '/path/to/pdftk/executable');
If your pdftk executable is /usr/bin/pdftk, then you do not have to pass it at all as this is the default.
for testing the encryption function (by default 128 bit encryption) , i created a pdf file 'apps.pdf' with password protected 'abcd' as password.
source code 1:
use PDF::Tk;
my $doc=PDF::Tk->new(pdftk=>'/apps/free/pdftk/1.44/bin/pdftk');
$doc->call_pdftk('apps.pdf', '1.128.pdf', 'owner_pw', 'abcd');
getting error:
Error: Unexpected command-line data:
owner_pw
where we were expecting an input PDF filename,
operation (e.g. "cat") or "input_pw". Exiting.
Errors encountered. No output created.
Done. Input errors, so no output created.
pdftk apps.pdf owner_pw abcd 1.128.pdf failed: 256 at /usr/lib/perl5/site_perl/5.10.0/PDF/Tk.pm line 73.
note: created a new pdf 'apps.pdf' with Document Open Password as 'abcd' and permission Password as 'abcd123'.
Please let me know how to resolve it.
I am writing a perl script that would send email about a the number of open cases and at the sametime will delete a directory which is more than 30 days old.
$age = -M;
if($age > 30)
{
remove_tree ($_);
}
This is what I am doing.Teh script was running fine but after 30 days It stopped running,not deleting the old directories and throws the following error.
Undefined subroutine &main::remove_tree called at /var/www/cgi-bin/remedy-case-
management/remedy-open-cases-script.pl line 35.
Not sure How i solve this.
I removed the paranthesis from remove_tree line and it throws error as follows.
Can't call method "remove_tree" without a package or object reference at /var/www/cgi-bin/remedy- case-management/remedy-open-cases-script.pl line 35.
Can anyone let me know what error i am making here?Thanks.
remove_tree is a function in File::Path.
Be sure to include that module before using the function:
use File::Path qw(remove_tree);
It seems you removed or commented out a line similar to
use File::Path qw{ remove_tree };
See File::Path.
I have a problem with module for Webmin, and I just want to resolve it with your help!
This is error that I get when I try do add new VirtualHost to Nginx module:
Error - Perl execution failed
Can't use string ("/home/www/website") as an ARRAY ref while "strict refs" in use at virtualmin-nginx-lib.pl line 247.
I don't really know where is problem, because I'm not Perl programmer.
There is a file: Pastebin
This seems to be a known issue:
http://www.virtualmin.com/node/23565
The solution seems to be adding the following line near the end of /etc/nginx/nginx.conf, within the http { ... } block:
include /etc/nginx/sites-enabled/*;