Last active
November 1, 2024 14:18
-
-
Save luzfcb/79b8105aa12f61c40c1553a3afb79b09 to your computer and use it in GitHub Desktop.
consulta CNJ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# para instalar as dependencias: | |
# python3 -m pip install zeep requests | |
from pathlib import Path | |
icp_cert_file_abs_path = str(Path(Path.home(), 'certs', 'icp_brasil_bundle.crt')) | |
print(icp_cert_file_abs_path) | |
import zeep # https://pypi.org/project/zeep/ | |
class Transport(zeep.transports.Transport): | |
def __init__(self, cache=None, timeout=300, operation_timeout=None, session=None): | |
super(Transport, self).__init__( | |
cache=cache, timeout=timeout, operation_timeout=operation_timeout, session=session | |
) | |
self.session.headers['Content-Type'] = 'text/xml; charset=utf-8' | |
self.session.headers['User-Agent'] = '{} ({})'.format( | |
'NOME_DO_BOT', | |
self.session.headers['User-Agent'] | |
) | |
# desativa validacao de certificado SSL/TLS | |
# solucao temporaria ate achar uma maneira de fazer | |
# python requests e openssl validar a cadeia de certificados | |
# emitidos pelo ICP-Brasil | |
# http://www.iti.gov.br/repositorio/84-repositorio/489-certificados-das-acs-da-icp-brasil-arquivo-unico-compactado | |
from requests import Session # https://pypi.org/project/requests/ | |
session = Session() | |
session.verify = icp_cert_file_abs_path | |
# start | |
# isso aqui desativa a validacao do certificado | |
# comente a linha abaixo para ver o erro | |
#session.verify = False | |
# end | |
transport = Transport(session=session) | |
# documentacao: http://www.cnj.jus.br/sgt/infWebService.php | |
url_webservice = "https://www.cnj.jus.br/sgt/sgt_ws.php?wsdl" | |
client = zeep.Client(wsdl=url_webservice, transport=transport) | |
response = client.service.getDataUltimaVersao() | |
dict_response = zeep.helpers.serialize_object(response) | |
print("\nVersão webservice CNJ é: ") | |
print(dict_response) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Require dos2unix unzip openssl | |
# | |
# Ubuntu: | |
# sudo apt-get install dos2unix | |
# OSX: | |
# brew install dos2unix | |
# | |
CERTS_BASE_FOLDER_NAME=$HOME/certs | |
CERTS_FOLDER_NAME=icp-brasil | |
CERTS_PACKAGE_URL=http://acraiz.icpbrasil.gov.br/credenciadas/CertificadosAC-ICP-Brasil/ACcompactado.zip | |
CERTS_DEST=${CERTS_BASE_FOLDER_NAME}/${CERTS_FOLDER_NAME} | |
mkdir -p ${CERTS_DEST} | |
cd ${CERTS_DEST} | |
rm ${CERTS_BASE_FOLDER_NAME}/icp_brasil_bundle.crt | |
rm -f *.crt | |
rm -f *.zip | |
wget "${CERTS_PACKAGE_URL}" | |
unzip ACcompactado.zip | |
for fn in $(file *.crt|grep data|sed 's/: *data//') | |
do | |
mv $fn $fn.der | |
openssl x509 -inform der -in $fn.der -out $fn | |
done | |
#rm *.der | |
for f in $(ls *.crt); do | |
dos2unix $f > /dev/null | |
openssl x509 -text -in $f >> ${CERTS_BASE_FOLDER_NAME}/icp_brasil_bundle.crt | |
done | |
echo -e "\n##############\nGenerated bundle cert file:\n" | |
echo -e "${CERTS_BASE_FOLDER_NAME}/icp_brasil_bundle.crt" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aqui foi com:
O certificado baixei em http://iti.gov.br/repositorio/84-repositorio/489-certificados-das-acs-da-icp-brasil-arquivo-unico-compactado