Skip to content

Instantly share code, notes, and snippets.

@vicmagpac
Forked from netojoaobatista/cielo.sh
Last active August 29, 2015 14:15
Show Gist options
  • Save vicmagpac/d9319cf4d8065c74aff6 to your computer and use it in GitHub Desktop.
Save vicmagpac/d9319cf4d8065c74aff6 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $EUID != 0 ]; then
echo 'Você precisa ser root para instalar certificados.'
exit $?
fi
# Diretório onde os certificados serão instalados
cert_path=`openssl version -d|sed 's/.*\"\(.*\)\"/\1/g'`/certs
# Path para o certificado da Cielo
ecommerce=$cert_path/ecommerce-cielo.crt
# Path para o certificado da intermediária
intermediaria=$cert_path/intermediaria-cielo.crt
# Path para o certificado raiz
raiz=$cert_path/raiz-cielo.crt
# Instalação do certificado raiz
echo "Criando certificado raiz em $raiz"
(cat << 'RAIZ-CIELO'
-----BEGIN CERTIFICATE-----
MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB
yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp
U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW
ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0
aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL
MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW
ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln
biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp
U2lnbiBDbG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FSDX9HoLPKsEdao7WNq
-----END CERTIFICATE-----
RAIZ-CIELO
) > $raiz
# Criando um link simbólico para o certificado utilizando seu hash
ln -s $raiz $cert_path/`openssl x509 -noout -hash -in $raiz`.0 &> /dev/null
# Verificando se o certificado foi instalado corretamente
openssl verify -CApath $cert_path $raiz
# Instalação do certificado da intermediária
echo "Criando certificado da intermediária em $intermediaria"
(cat << 'INTERMEDIARIA-CIELO'
-----BEGIN CERTIFICATE-----
MIIFKzCCBBOgAwIBAgIQfuFKb2/v8tN/P61lTTratDANBgkqhkiG9w0BAQsFADCB
yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp
U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW
ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0
aG9yaXR5IC0gRzUwHhcNMTMxMDMxMDAwMDAwWhcNMjMxMDMwMjM1OTU5WjB3MQsw
CQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAdBgNV
BAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMTH1N5bWFudGVjIENs
YXNzIDMgRVYgU1NMIENBIC0gRzMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
AoIBAQDYoWV0I+grZOIy1zM3PY71NBZI3U9/hxz4RCMTjvsR2ERaGHGOYBYmkpv9
FwvhcXBC/r/6HMCqo6e1cej/GIP23xAKE2LIPZyn3i4/DNkd5y77Ks7Imn+Hv9hM
BBUyydHMlXGgTihPhNk1++OGb5RT5nKKY2cuvmn2926OnGAE6yn6xEdC0niY4+wL
pZLct5q9gGQrOHw4CVtm9i2VeoayNC6FnpAOX7ddpFFyRnATv2fytqdNFB5suVPu
IxpOjUhVQ0GxiXVqQCjFfd3SbtICGS97JJRL6/EaqZvjI5rq+jOrCiy39GAI3Z8c
zd0tAWaAr7MvKR0juIrhoXAHDDQPAgMBAAGjggFdMIIBWTAvBggrBgEFBQcBAQQj
MCEwHwYIKwYBBQUHMAGGE2h0dHA6Ly9zMi5zeW1jYi5jb20wEgYDVR0TAQH/BAgw
BgEB/wIBADBlBgNVHSAEXjBcMFoGBFUdIAAwUjAmBggrBgEFBQcCARYaaHR0cDov
L3d3dy5zeW1hdXRoLmNvbS9jcHMwKAYIKwYBBQUHAgIwHBoaaHR0cDovL3d3dy5z
eW1hdXRoLmNvbS9ycGEwMAYDVR0fBCkwJzAloCOgIYYfaHR0cDovL3MxLnN5bWNi
LmNvbS9wY2EzLWc1LmNybDAOBgNVHQ8BAf8EBAMCAQYwKQYDVR0RBCIwIKQeMBwx
GjAYBgNVBAMTEVN5bWFudGVjUEtJLTEtNTMzMB0GA1UdDgQWBBQBWavn3ToLWaZk
Y9bPIAdX1ZHnajAfBgNVHSMEGDAWgBR/02Wnwt3su/AwCfNDOfoCrzMxMzANBgkq
hkiG9w0BAQsFAAOCAQEAQgFVe9AWGl1Y6LubqE3X89frE5SG1n8hC0e8V5uSXU8F
nzikEHzPg74GQ0aNCLxq1xCm+quvL2GoY/Jl339MiBKIT7Np2f8nwAqXkY9W+4nE
qLuSLRtzsMarNvSWbCAI7woeZiRFT2cAQMgHVHQzO6atuyOfZu2iRHA0+w7qAf3P
eHTfp61Vt19N9tY/4IbOJMdCqRMURDVLtt/JYKwMf9mTIUvunORJApjTYHtcvNUw
LwfORELEC5n+5p/8sHiGUW3RLJ3GlvuFgrsEL/digO9i2n/2DqyQuFa9eT/ygG6j
2bkPXToHHZGThkspTOHcteHgM52zyzaRS/6htO7w+Q==
-----END CERTIFICATE-----
INTERMEDIARIA-CIELO
) > $intermediaria
# Criando um link simbólico para o certificado utilizando seu hash
ln -s $intermediaria $cert_path/`openssl x509 -noout -hash -in $intermediaria`.0 &> /dev/null
# Verificando se o certificado foi instalado corretamente
openssl verify -CApath $cert_path $intermediaria
# Instalação do certificado Cielo
echo "Criando certificado ecommerce da Cielo em $ecommerce"
(cat << 'ECOMMERCE-CIELO'
-----BEGIN CERTIFICATE-----
MIIGmDCCBYCgAwIBAgIQPDxPqKXUhELIzHCju7K71DANBgkqhkiG9w0BAQsFADB3
MQswCQYDVQQGEwJVUzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAd
BgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMTH1N5bWFudGVj
IENsYXNzIDMgRVYgU1NMIENBIC0gRzMwHhcNMTUwMTE0MDAwMDAwWhcNMTYwMTE0
MjM1OTU5WjCCARoxEzARBgsrBgEEAYI3PAIBAxMCQlIxHTAbBgNVBA8TFFByaXZh
dGUgT3JnYW5pemF0aW9uMRswGQYDVQQFExIwMS4wMjcuMDU4LzAwMDEtOTExCzAJ
BgNVBAYTAkJSMREwDwYDVQQRDAgwNjQ1NDA1MDESMBAGA1UECAwJU2FvIFBhdWxv
MRAwDgYDVQQHDAdCYXJ1ZXJpMRYwFAYDVQQJDA0yMTkgQWwgR3JhamF1MRMwEQYD
VQQKDApDSUVMTyBTLkEuMTMwMQYDVQQLDCpUZXJtcyBvZiB1c2UgYXQgd3d3LnZl
cmlzaWduLmNvbS9ycGEgKGMpMDUxHzAdBgNVBAMMFmVjb21tZXJjZS5jaWVsby5j
b20uYnIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+93ljI0eXq17a
ZzGhb7z19R6z04jbF6UTFy3pEauwW2HYRMl59AgIa/qt/g4j84BB5EE5mEn7XP2Q
WTtIWFD81O6pEB9z7ep06zH4QbROA3yVItYt6P+OE7e7/d+jOUSmCf7hLs7J1fGa
MCiM4533TPuJzWENS4bI5baw8OjkOSXfSyT31lj8UW2uNNVxR1ZXWjqrpAV3Gtqk
vo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F2nVJg1zL1Vv/QUnam3lMm/uDL4jv9OzjDkm9I
vSFgTDqaOXFkDRc8QfzsPiZvweLtHLJhEMcRLoUan/kHLxxV7mM/YOuMim/39dcj
hV9J9xZZRX2kQ/tT/kE1z8IyQ2FaWwSvjQqj6nneRys1VhNMmzxsfNR24zvNZn1n
wZCkIxEOWypNIJsikfKRbSmf71FGMwdPTa+nZZxmEsth3Q9zik03Skys3dgN8RFz
lpR/gA2p4bpuGKDFIRegsGGAeks2u95xxI9sTk2q7XhFt+xktwMn32JF/ZlRgFEx
w9gWQillv3FZH6wm
-----END CERTIFICATE-----
ECOMMERCE-CIELO
) > $ecommerce
# Criando um link simbólico para o certificado utilizando seu hash
ln -s $ecommerce $cert_path/`openssl x509 -noout -hash -in $ecommerce`.0 &> /dev/null
# Verificando se o certificado foi instalado corretamente
openssl verify -CApath $cert_path $ecommerce
# Exibindo informações do certificado instalado
openssl x509 -in $ecommerce -text -noout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment