mirror of
https://github.com/CAcertOrg/cats.git
synced 2024-11-08 07:04:03 +00:00
Changes proposed by Felix Dörre, plus making the file location invariant
This commit is contained in:
parent
7a213874f2
commit
db5cb0dce6
1 changed files with 16 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
use Socket;
|
use Socket;
|
||||||
use Net::SSLeay qw(die_now die_if_ssl_error) ;
|
use Net::SSLeay qw(die_now die_if_ssl_error) ;
|
||||||
use DBI;
|
use DBI;
|
||||||
|
use Cwd 'abs_path';
|
||||||
|
|
||||||
# Be sure the CertFile includes a key chain if you are using class 3 certificates
|
# Be sure the CertFile includes a key chain if you are using class 3 certificates
|
||||||
my $CertFile;
|
my $CertFile;
|
||||||
|
@ -9,7 +10,18 @@ my $KeyFile;
|
||||||
my $CAfile = "CAcert_roots.pem";
|
my $CAfile = "CAcert_roots.pem";
|
||||||
my $TargetHost="secure.cacert.org";
|
my $TargetHost="secure.cacert.org";
|
||||||
my $TargetScript="cats/cats_import.php";
|
my $TargetScript="cats/cats_import.php";
|
||||||
my $ConnectInc="/home/cats/public_html/includes/db_connect.inc";
|
#my $ConnectInc="/home/cats/public_html/includes/db_connect.inc";
|
||||||
|
# Trying to be location invariant...
|
||||||
|
my $ConnectInc=my_dir() . "/../includes/db_connect.inc";
|
||||||
|
|
||||||
|
sub my_dir()
|
||||||
|
{
|
||||||
|
my $dir = abs_path($0);
|
||||||
|
#Strip filename
|
||||||
|
$dir =~ s/\/[^\/]+$//;
|
||||||
|
|
||||||
|
return $dir;
|
||||||
|
}
|
||||||
|
|
||||||
sub url_encode($)
|
sub url_encode($)
|
||||||
{
|
{
|
||||||
|
@ -176,7 +188,7 @@ $sth = $dbh->prepare("SELECT `lp`.`lp_id`, `lp`.`user_id`, `lp`.`root`, `tt`.`te
|
||||||
"FROM `learnprogress` AS `lp`, `topics` AS `t`, `topic_type` AS `tt` ".
|
"FROM `learnprogress` AS `lp`, `topics` AS `t`, `topic_type` AS `tt` ".
|
||||||
"WHERE `lp`.`t_id`=`t`.`t_id` AND `lp`.`percentage` >= `t`.`percentage` AND `lp`.`correct`>0 ".
|
"WHERE `lp`.`t_id`=`t`.`t_id` AND `lp`.`percentage` >= `t`.`percentage` AND `lp`.`correct`>0 ".
|
||||||
" AND `t`.`type_id`=`tt`.`type_id` ".
|
" AND `t`.`type_id`=`tt`.`type_id` ".
|
||||||
" AND `t`.`type_id` in (1, 3) ". # Upload Assurer Challenge and Triage challenge
|
" AND `t`.`type_id` in (1, 3, 4) ". # Upload Assurer Challenge, Triage challenge and Data Privacy Quiz
|
||||||
" AND `lp`.`uploaded` IS NULL");
|
" AND `lp`.`uploaded` IS NULL");
|
||||||
if (!$sth->execute()) {
|
if (!$sth->execute()) {
|
||||||
die($sth->errstr);
|
die($sth->errstr);
|
||||||
|
@ -184,6 +196,7 @@ if (!$sth->execute()) {
|
||||||
|
|
||||||
$port = 443;
|
$port = 443;
|
||||||
$dest_ip = gethostbyname ($TargetHost);
|
$dest_ip = gethostbyname ($TargetHost);
|
||||||
|
|
||||||
$dest_serv_params = sockaddr_in($port, $dest_ip);
|
$dest_serv_params = sockaddr_in($port, $dest_ip);
|
||||||
|
|
||||||
# Exchange data
|
# Exchange data
|
||||||
|
@ -213,6 +226,7 @@ do {
|
||||||
Net::SSLeay::CTX_use_PrivateKey_file($ctx, $KeyFile, &Net::SSLeay::FILETYPE_PEM);
|
Net::SSLeay::CTX_use_PrivateKey_file($ctx, $KeyFile, &Net::SSLeay::FILETYPE_PEM);
|
||||||
|
|
||||||
$ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!");
|
$ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!");
|
||||||
|
Net::SSLeay::set_tlsext_host_name($ssl, $TargetHost);
|
||||||
Net::SSLeay::set_fd($ssl, fileno(S)); # Must use fileno
|
Net::SSLeay::set_fd($ssl, fileno(S)); # Must use fileno
|
||||||
$res = Net::SSLeay::connect($ssl) and die_if_ssl_error("ssl connect");
|
$res = Net::SSLeay::connect($ssl) and die_if_ssl_error("ssl connect");
|
||||||
#print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";
|
#print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n";
|
||||||
|
|
Loading…
Reference in a new issue