Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
contrib
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rafael Bidegain
contrib
Commits
c092b520
Commit
c092b520
authored
4 years ago
by
Rafael Bidegain
Browse files
Options
Downloads
Patches
Plain Diff
tsa2.php es un script en php fork de tsa2.sh, sella y verifica ejecutandolo desde una consola.
parent
8df94473
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tsa2.php
+99
-0
99 additions, 0 deletions
tsa2.php
with
99 additions
and
0 deletions
tsa2.php
0 → 100644
+
99
−
0
View file @
c092b520
#!/usr/bin/env php
<?php
#
# tsa2.php en un script en php para Sellar y/o Verificar un archivo en la BFA.
# basado en tsa2.sh de Robert Martin-Legene
# Autor: Rafael Bidegain, rbidegain@loteriadelaciudad.gob.ar
#
# Licencia: GPLv2-only, 21 de mayo de 2021
#
function
existeArchivo
(
$file
)
{
return
is_file
(
$file
);
}
function
getSha
(
$file
)
{
return
hash_file
(
'sha256'
,
$file
);
}
function
firmar
(
$hash
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
"https://tsa2.buenosaires.gob.ar:443/stamp"
);
#curl_setopt($ch, CURLOPT_URL, "http://tsa.ultimamilla.com.ar/stamp");
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
"
{
\"hashes\":[\"$hash\"]
}
"
);
$headers
=
array
();
$headers
[]
=
'Content-Type: application/json'
;
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$headers
);
$result
=
curl_exec
(
$ch
);
if
(
curl_errno
(
$ch
))
{
echo
'Error:'
.
curl_error
(
$ch
);
}
curl_close
(
$ch
);
}
function
verificar
(
$hash
){
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
"https://tsa2.buenosaires.gob.ar:443/verify/
$hash
"
);
#curl_setopt($ch, CURLOPT_URL, "http://tsa.ultimamilla.com.ar/verify/$hash");
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
$result
=
curl_exec
(
$ch
);
if
(
curl_errno
(
$ch
))
{
echo
'Error:'
.
curl_error
(
$ch
);
}
else
{
print
"
$result
\n
"
;
}
curl_close
(
$ch
);
}
function
formaDeUso
(){
print
"forma de uso:
\n
"
;
print
"./tsa2.php stamp|verify archivo
\n
"
;
}
#---------------------------------------------------------------------
# Comienzo
#---------------------------------------------------------------------
if
(
$argc
!=
3
)
{
print
"ERROR. Se requieren dos argumentos
\n\n
"
;
formaDeUso
();
exit
(
1
);
}
$archivo
=
$argv
[
2
];
if
(
existeArchivo
(
$archivo
)
)
{
$sha
=
getSha
(
$archivo
);
#print "$sha\n";
switch
(
$argv
[
1
])
{
case
"stamp"
:
firmar
(
$sha
);
break
;
case
"verify"
:
verificar
(
$sha
);
break
;
default
:
print
"ERROR. La acción a realizar debe ser stamp o verify
\n
"
;
print
"
\"
$argv[1]
\"
no es una acción contemplada
\n\n
"
;
formaDeUso
();
exit
(
1
);
}
}
else
{
print
"No existe el archivo
$archivo
\n\n
"
;
formaDeUso
();
exit
(
1
);
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment