zatca 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/einvoicing-sdk/Apps/fatoora +12 -0
- data/einvoicing-sdk/Apps/fatoora.bat +16 -0
- data/einvoicing-sdk/Apps/global.json +1 -0
- data/einvoicing-sdk/Apps/jq.exe +0 -0
- data/einvoicing-sdk/Apps/zatca-einvoicing-sdk-238-R3.2.7.jar +0 -0
- data/einvoicing-sdk/Configuration/config.json +11 -0
- data/einvoicing-sdk/Configuration/defaults.json +11 -0
- data/einvoicing-sdk/Configuration/jq.exe +0 -0
- data/einvoicing-sdk/Configuration/usage.txt +16 -0
- data/einvoicing-sdk/Data/Certificates/cert.pem +1 -0
- data/einvoicing-sdk/Data/Certificates/ec-secp256k1-priv-key.pem +1 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-AR-VAT-Group.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-AR.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-EN-VAT-group.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-example-EN.properties +9 -0
- data/einvoicing-sdk/Data/Input/csr-config-template.properties +9 -0
- data/einvoicing-sdk/Data/PIH/pih.txt +1 -0
- data/einvoicing-sdk/Data/Rules/schematrons/20210819_ZATCA_E-invoice_Validation_Rules.xsl +2844 -0
- data/einvoicing-sdk/Data/Rules/schematrons/CEN-EN16931-UBL.xsl +1973 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Simplified Debit Note.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Credit Note.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Debit Note.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Standard Invoice.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/PDF-A3/Tax_Invoice_USD.pdf +0 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Credit/Simplified_Credit_Note.xml +300 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Credit/Simplified_Credit_Note_Error.xml +225 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Debit/Simplified_Debit_Note.xml +211 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Debit/Simplified_Debit_Note_Error.xml +226 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Additional_Simplified_Invoices/Out_Of_Scope_Simplified_Invoice.xml +207 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Additional_Simplified_Invoices/Simplified_Invoice_USD.xml +246 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Simplified_Invoice.xml +246 -0
- data/einvoicing-sdk/Data/Samples/Simplified/Invoice/Simplified_Invoice_Error.xml +228 -0
- data/einvoicing-sdk/Data/Samples/Standard/Credit/Standard_Credit_Note.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Credit/Standard_Credit_Note_Error.xml +224 -0
- data/einvoicing-sdk/Data/Samples/Standard/Debit/Standard_Debit_Note.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Debit/Standard_Debit_Note_Error.xml +226 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Exempt_Standard_Invoice.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Standard_Invoice_USD.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Additional_Standard_Invoices/Zero_Rate_Standard_Invoice.xml +227 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Sample Invoice[Advance Payements] - 1.xml +294 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Sample Invoice[Advance Payements] - 2.xml +432 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Standard_Invoice.xml +222 -0
- data/einvoicing-sdk/Data/Samples/Standard/Invoice/Standard_Invoice_Error.xml +228 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/CCTS_CCT_SchemaModule-2.1.xsd +731 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonAggregateComponents-2.1.xsd +44365 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonBasicComponents-2.1.xsd +5389 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonExtensionComponents-2.1.xsd +223 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CommonSignatureComponents-2.1.xsd +101 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-CoreComponentParameters-2.1.xsd +63 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-ExtensionContentDataType-2.1.xsd +89 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-QualifiedDataTypes-2.1.xsd +69 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-SignatureAggregateComponents-2.1.xsd +138 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-SignatureBasicComponents-2.1.xsd +78 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-UnqualifiedDataTypes-2.1.xsd +553 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-XAdESv132-2.1.xsd +476 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-XAdESv141-2.1.xsd +25 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/common/UBL-xmldsig-core-schema-2.1.xsd +330 -0
- data/einvoicing-sdk/Data/Schemas/xsds/UBL2.1/xsd/maindoc/UBL-Invoice-2.1.xsd +1002 -0
- data/einvoicing-sdk/Dockerfile +26 -0
- data/einvoicing-sdk/LICENSE.txt +56 -0
- data/einvoicing-sdk/Lib/.Net/DLL/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/DLL/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/System.Net.Http.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/DLL/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/3f204b7a-faba-42d8-8288-8b6fe516555c.vsidx +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/f95b6f91-c110-4b7a-bb49-3fc6bde85b13.vsidx +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/FileContentIndex/read.lock +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/.vs/SDKNETFrameworkTest/v17/.suo +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/App.config +14 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/CSRGeneratorOpenSSL.cs +58 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Program.cs +194 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Properties/AssemblyInfo.cs +36 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/Readme.txt +8 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.csproj +120 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.exe.config +20 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/SDKNETFrameworkTest.sln +25 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/certificate.txt +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/pih.txt +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/Data/privateKey.txt +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.exe.config +20 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/System.Net.Http.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/bin/Debug/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs +4 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/DesignTimeResolveAssemblyReferences.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.AssemblyReference.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.CopyComplete +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.CoreCompileInputs.cache +1 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.FileListAbsolute.txt +22 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.csproj.SuggestedBindingRedirects.cache +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/obj/Debug/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/SDKNETFrameworkTest/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/Lib/.Net/Test/BouncyCastle.Crypto.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Core.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Text.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.Util.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.OpenJDK.XML.API.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/IKVM.Runtime.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.dll.config +43 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameWorkLib.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.exe +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.exe.config +20 -0
- data/einvoicing-sdk/Lib/.Net/Test/SDKNETFrameworkTest.pdb +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/saxon-he-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/saxon-he-api-10.8.dll +0 -0
- data/einvoicing-sdk/Lib/.Net/Test/saxon-he-api-10.8.xml +11759 -0
- data/einvoicing-sdk/README.md +15 -0
- data/einvoicing-sdk/Readme/readme.docx +0 -0
- data/einvoicing-sdk/Readme/readme.md +674 -0
- data/einvoicing-sdk/Readme/readme.pdf +0 -0
- data/einvoicing-sdk/Readme/~$readme.docx +0 -0
- data/einvoicing-sdk/docker-compose.yml +12 -0
- data/einvoicing-sdk/install.bat +74 -0
- data/einvoicing-sdk/install.sh +74 -0
- data/lib/zatca/client.rb +173 -0
- data/lib/zatca/hacks.rb +45 -0
- data/lib/zatca/hashing.rb +18 -0
- data/lib/zatca/qr_code_extractor.rb +31 -0
- data/lib/zatca/qr_code_generator.rb +9 -2
- data/lib/zatca/signing/certificate.rb +78 -0
- data/lib/zatca/signing/csr.rb +220 -0
- data/lib/zatca/signing/ecdsa.rb +59 -0
- data/lib/zatca/tag.rb +18 -8
- data/lib/zatca/tags.rb +5 -1
- data/lib/zatca/tags_schema.rb +5 -5
- data/lib/zatca/types.rb +7 -0
- data/lib/zatca/ubl/base_component.rb +142 -0
- data/lib/zatca/ubl/builder.rb +166 -0
- data/lib/zatca/ubl/common_aggregate_components/allowance_charge.rb +64 -0
- data/lib/zatca/ubl/common_aggregate_components/classified_tax_category.rb +25 -0
- data/lib/zatca/ubl/common_aggregate_components/delivery.rb +27 -0
- data/lib/zatca/ubl/common_aggregate_components/invoice_line.rb +63 -0
- data/lib/zatca/ubl/common_aggregate_components/item.rb +21 -0
- data/lib/zatca/ubl/common_aggregate_components/legal_monetary_total.rb +59 -0
- data/lib/zatca/ubl/common_aggregate_components/party.rb +28 -0
- data/lib/zatca/ubl/common_aggregate_components/party_identification.rb +25 -0
- data/lib/zatca/ubl/common_aggregate_components/party_legal_entity.rb +19 -0
- data/lib/zatca/ubl/common_aggregate_components/party_tax_scheme.rb +30 -0
- data/lib/zatca/ubl/common_aggregate_components/postal_address.rb +59 -0
- data/lib/zatca/ubl/common_aggregate_components/price.rb +20 -0
- data/lib/zatca/ubl/common_aggregate_components/tax_category.rb +56 -0
- data/lib/zatca/ubl/common_aggregate_components/tax_total.rb +58 -0
- data/lib/zatca/ubl/common_aggregate_components.rb +2 -0
- data/lib/zatca/ubl/invoice.rb +481 -0
- data/lib/zatca/ubl/invoice_subtype_builder.rb +50 -0
- data/lib/zatca/ubl/signing/cert.rb +48 -0
- data/lib/zatca/ubl/signing/invoice_signed_data_reference.rb +44 -0
- data/lib/zatca/ubl/signing/key_info.rb +25 -0
- data/lib/zatca/ubl/signing/object.rb +20 -0
- data/lib/zatca/ubl/signing/qualifying_properties.rb +27 -0
- data/lib/zatca/ubl/signing/signature.rb +50 -0
- data/lib/zatca/ubl/signing/signature_information.rb +19 -0
- data/lib/zatca/ubl/signing/signature_properties_reference.rb +26 -0
- data/lib/zatca/ubl/signing/signed_info.rb +21 -0
- data/lib/zatca/ubl/signing/signed_properties.rb +81 -0
- data/lib/zatca/ubl/signing/signed_signature_properties.rb +23 -0
- data/lib/zatca/ubl/signing/ubl_document_signatures.rb +25 -0
- data/lib/zatca/ubl/signing/ubl_extension.rb +22 -0
- data/lib/zatca/ubl/signing/ubl_extensions.rb +17 -0
- data/lib/zatca/ubl/signing.rb +2 -0
- data/lib/zatca/ubl.rb +2 -0
- data/lib/zatca/version.rb +1 -1
- data/lib/zatca.rb +27 -3
- data/zatca.gemspec +52 -0
- metadata +318 -10
- data/Gemfile.lock +0 -100
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
@echo off
|
3
|
+
|
4
|
+
SET MY_PATH=%~dp0
|
5
|
+
|
6
|
+
setx /U %USERDOMAIN%/%USERNAME% /S %COMPUTERNAME% SDK_CONFIG %MY_PATH%Configuration/config.json
|
7
|
+
setx /U %USERDOMAIN%/%USERNAME% /S %COMPUTERNAME% FATOORA_HOME %MY_PATH%Apps\
|
8
|
+
SETX PATH ""
|
9
|
+
SETX PATH "%MY_PATH%Apps\;%PATH%"
|
10
|
+
|
11
|
+
cd Configuration
|
12
|
+
|
13
|
+
set "CURRENT=%~dp0"
|
14
|
+
set "_path=%CURRENT%Configuration"
|
15
|
+
|
16
|
+
for %%a in (%_path:~0,-1%) do set "p2_dir=%%~dpa"\
|
17
|
+
|
18
|
+
set p2_dir=%p2_dir:\=\\%
|
19
|
+
|
20
|
+
SET XSD=
|
21
|
+
FOR /F %%I IN ('jq .xsdPath defaults.json ') DO set "XSD=%%I"
|
22
|
+
|
23
|
+
SET XSD_filename=
|
24
|
+
for %%F in (%XSD%) do set "XSD_filename=%%~nxF"
|
25
|
+
|
26
|
+
SET EN_SCHEMA=
|
27
|
+
FOR /F %%I IN ('jq .enSchematron defaults.json ') DO set "EN_SCHEMA=%%I"
|
28
|
+
SET EN_SCHEMA_filename=
|
29
|
+
for %%F in (%EN_SCHEMA%) do set "EN_SCHEMA_filename=%%~nxF"
|
30
|
+
|
31
|
+
|
32
|
+
SET ZATCA_SCHEMA=
|
33
|
+
FOR /F %%I IN ('jq .zatcaSchematron defaults.json ') DO set "ZATCA_SCHEMA=%%I"
|
34
|
+
SET ZATCA_SCHEMA_filename=
|
35
|
+
for %%F in (%ZATCA_SCHEMA%) do set "ZATCA_SCHEMA_filename=%%~nxF"
|
36
|
+
|
37
|
+
SET CERT=
|
38
|
+
FOR /F %%I IN ('jq .certPath defaults.json ') DO set "CERT=%%I"
|
39
|
+
SET CERT_filename=
|
40
|
+
for %%F in (%CERT%) do set "CERT_filename=%%~nxF"
|
41
|
+
|
42
|
+
SET PK=
|
43
|
+
FOR /F %%I IN ('jq .privateKeyPath defaults.json ') DO set "PK=%%I"
|
44
|
+
SET PK_filename=
|
45
|
+
for %%F in (%PK%) do set "PK_filename=%%~nxF"
|
46
|
+
|
47
|
+
SET PIH=
|
48
|
+
FOR /F %%I IN ('jq .pihPath defaults.json ') DO set "PIH=%%I"
|
49
|
+
SET PIH_filename=
|
50
|
+
for %%F in (%PIH%) do set "PIH_filename=%%~nxF"
|
51
|
+
|
52
|
+
SET CERT_PASSWORD=
|
53
|
+
FOR /F %%I IN ('jq .certPassword defaults.json ') DO set "CERT_PASSWORD=%%I"
|
54
|
+
SET CERT_PASSWORD_VALUE=
|
55
|
+
for %%F in (%CERT_PASSWORD%) do set "CERT_PASSWORD_VALUE=%%~nxF"
|
56
|
+
|
57
|
+
SET usage=
|
58
|
+
FOR /F %%I IN ('jq .usagePathFile defaults.json ') DO set "usage=%%I"
|
59
|
+
SET usage_filename=
|
60
|
+
for %%F in (%usage%) do set "usage_filename=%%~nxF"
|
61
|
+
|
62
|
+
|
63
|
+
echo { "xsdPath" : "%p2_dir%Data\\Schemas\\xsds\\UBL2.1\\xsd\\maindoc\\%XSD_filename%", ^
|
64
|
+
"enSchematron":"%p2_dir%Data\\Rules\\schematrons\\%EN_SCHEMA_filename%", ^
|
65
|
+
"zatcaSchematron":"%p2_dir%Data\\Rules\\schematrons\\%ZATCA_SCHEMA_filename%", ^
|
66
|
+
"certPath":"%p2_dir%Data\\Certificates\\%CERT_filename%",^
|
67
|
+
"privateKeyPath":"%p2_dir%Data\\Certificates\\%PK_filename%",^
|
68
|
+
"pihPath" : "%p2_dir%Data\\PIH\\%PIH_filename%",^
|
69
|
+
"certPassword" : "%CERT_PASSWORD_VALUE%",^
|
70
|
+
"inputPath" : "%p2_dir%Data\\Input",^
|
71
|
+
"usagePathFile":"%p2_dir%Configuration\\%usage_filename%"^
|
72
|
+
} > config.json
|
73
|
+
|
74
|
+
cd ../
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
export FATOORA_HOME="${PWD}"
|
3
|
+
|
4
|
+
export PATH=$PATH:$FATOORA_HOME/Apps/
|
5
|
+
#export PATH
|
6
|
+
#export FATOORA_HOME
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
touch ~/.zshrc
|
11
|
+
touch ~/.bash-profile
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
SDK_CONFIG="${PWD}/Configuration/config.json"
|
17
|
+
|
18
|
+
|
19
|
+
echo "export PATH=$PATH:$FATOORA_HOME/Apps/" >> ~/.bash-profile
|
20
|
+
echo "export FATOORA_HOME=${PWD}/Apps" >> ~/.bash-profile
|
21
|
+
echo "export SDK_CONFIG=$SDK_CONFIG" >> ~/.bash-profile
|
22
|
+
|
23
|
+
echo "export PATH=$PATH:$FATOORA_HOME/Apps/" >> ~/.zshrc
|
24
|
+
echo "export FATOORA_HOME=${PWD}/Apps" >> ~/.zshrc
|
25
|
+
echo "export SDK_CONFIG=$SDK_CONFIG" >> ~/.zshrc
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
source ~/.bash-profile
|
32
|
+
source ~/.zshrc
|
33
|
+
|
34
|
+
cd Configuration
|
35
|
+
|
36
|
+
parentDir="$(dirname "$PWD")"
|
37
|
+
|
38
|
+
xsdPath=$(jq -r '.xsdPath' defaults.json)
|
39
|
+
xsdPathFileName="$(basename $xsdPath)"
|
40
|
+
|
41
|
+
enSchematron=$(jq -r '.enSchematron' defaults.json)
|
42
|
+
enSchematronFileName="$(basename $enSchematron)"
|
43
|
+
|
44
|
+
zatcaSchematron=$(jq -r '.zatcaSchematron' defaults.json)
|
45
|
+
zatcaSchematronFileName="$(basename $zatcaSchematron)"
|
46
|
+
|
47
|
+
certPath=$(jq -r '.certPath' defaults.json)
|
48
|
+
certPathFileName="$(basename $certPath)"
|
49
|
+
|
50
|
+
pkPath=$(jq -r '.privateKeyPath' defaults.json)
|
51
|
+
pkPathFileName="$(basename $pkPath)"
|
52
|
+
|
53
|
+
pihPath=$(jq -r '.pihPath' defaults.json)
|
54
|
+
pihPathFileName="$(basename $pihPath)"
|
55
|
+
|
56
|
+
certPassword=$(jq -r '.certPassword' defaults.json)
|
57
|
+
certPasswordValue="$(basename $certPassword)"
|
58
|
+
|
59
|
+
usagePath=$(jq -r '.usagePathFile' defaults.json)
|
60
|
+
usagePathFileName="$(basename $usagePath)"
|
61
|
+
|
62
|
+
|
63
|
+
jq -n '{"xsdPath":$one, "enSchematron":$two, "zatcaSchematron":$thr,"certPath":$fou, "privateKeyPath":$fiv ,"pihPath":$six ,"certPassword":$sev ,"inputPath":$eight,"usagePathFile":$nine}' \
|
64
|
+
--arg one "${parentDir}/Data/Schemas/xsds/UBL2.1/xsd/maindoc/$xsdPathFileName" \
|
65
|
+
--arg two "${parentDir}/Data/Rules/schematrons/$enSchematronFileName" \
|
66
|
+
--arg thr "${parentDir}/Data/Rules/schematrons/$zatcaSchematronFileName" \
|
67
|
+
--arg fou "${parentDir}/Data/Certificates/$certPathFileName" \
|
68
|
+
--arg fiv "${parentDir}/Data/Certificates/$pkPathFileName" \
|
69
|
+
--arg six "${parentDir}/Data/PIH/$pihPathFileName" \
|
70
|
+
--arg sev "$certPasswordValue" \
|
71
|
+
--arg eight "${parentDir}/Data/Input" \
|
72
|
+
--arg nine "${parentDir}/Configuration/$usagePathFileName" >config.json
|
73
|
+
|
74
|
+
cd ../
|
data/lib/zatca/client.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
require "httpx"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# This wraps the API described here:
|
5
|
+
# https://sandbox.zatca.gov.sa/IntegrationSandbox
|
6
|
+
class ZATCA::Client
|
7
|
+
# API URLs are not present in developer portal, they can only be found in a PDF
|
8
|
+
# called Fatoora Portal User Manual, here:
|
9
|
+
# https://zatca.gov.sa/en/E-Invoicing/Introduction/Guidelines/Documents/Fatoora%20portal%20user%20manual.pdf
|
10
|
+
PRODUCTION_BASE_URL = "https://gw-fatoora.zatca.gov.sa/e-invoicing/core".freeze
|
11
|
+
SANDBOX_BASE_URL = "https://gw-apic-gov.gazt.gov.sa/e-invoicing/developer-portal".freeze
|
12
|
+
SIMULATION_BASE_URL = "https://gw-fatoora.zatca.gov.sa/e-invoicing/simulation".freeze
|
13
|
+
|
14
|
+
ENVIRONMENTS_TO_URLS_MAP = {
|
15
|
+
production: PRODUCTION_BASE_URL,
|
16
|
+
sandbox: SANDBOX_BASE_URL,
|
17
|
+
simulation: SIMULATION_BASE_URL
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
DEFAULT_API_VERSION = "V2".freeze
|
21
|
+
LANGUAGES = %w[ar en].freeze
|
22
|
+
|
23
|
+
def initialize(username:, password:, language: "ar", version: DEFAULT_API_VERSION, environment: :production)
|
24
|
+
raise "Invalid language: #{language}, Please use one of: #{LANGUAGES}" unless LANGUAGES.include?(language)
|
25
|
+
|
26
|
+
@username = username
|
27
|
+
@password = password
|
28
|
+
@language = language
|
29
|
+
@version = version
|
30
|
+
|
31
|
+
@base_url = ENVIRONMENTS_TO_URLS_MAP[environment.to_sym] || PRODUCTION_BASE_URL
|
32
|
+
end
|
33
|
+
|
34
|
+
# Reporting API
|
35
|
+
def report_invoice(uuid:, invoice_hash:, invoice:, cleared:)
|
36
|
+
request(
|
37
|
+
path: "invoices/reporting/single",
|
38
|
+
method: :post,
|
39
|
+
body: {
|
40
|
+
uuid: uuid,
|
41
|
+
invoiceHash: invoice_hash,
|
42
|
+
invoice: invoice
|
43
|
+
},
|
44
|
+
headers: {
|
45
|
+
"Clearance-Status" => cleared ? "1" : "0"
|
46
|
+
}
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Clearance API
|
51
|
+
def clear_invoice(uuid:, invoice_hash:, invoice:, cleared:)
|
52
|
+
request(
|
53
|
+
path: "invoices/clearance/single",
|
54
|
+
method: :post,
|
55
|
+
body: {
|
56
|
+
uuid: uuid,
|
57
|
+
invoiceHash: invoice_hash,
|
58
|
+
invoice: invoice
|
59
|
+
},
|
60
|
+
headers: {
|
61
|
+
"Clearance-Status" => cleared ? "1" : "0"
|
62
|
+
}
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Compliance CSID API
|
67
|
+
# This should be used to obtain credentials to issue a certificate in the next
|
68
|
+
# request (issue_production_csid)
|
69
|
+
#
|
70
|
+
# csid stands for Cryptographic Stamp Identifier
|
71
|
+
#
|
72
|
+
# csr stands for Certificate Signing Request
|
73
|
+
# You should generate this via the ZATCA::Signing::CSR class
|
74
|
+
#
|
75
|
+
# otp stands for One Time Password.
|
76
|
+
# You can get this from the fatoora portal
|
77
|
+
# Returns:
|
78
|
+
# {
|
79
|
+
# "binarySecurityToken": "string" # To be used as a username in next request
|
80
|
+
# "secret": "string" # To be used as a password in next request
|
81
|
+
# }
|
82
|
+
def issue_csid(csr:, otp:)
|
83
|
+
request(
|
84
|
+
path: "compliance",
|
85
|
+
method: :post,
|
86
|
+
body: {csr: csr},
|
87
|
+
headers: {"OTP" => otp},
|
88
|
+
authenticated: false
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Compliance Invoice API
|
93
|
+
def compliance_check(uuid:, invoice_hash:, invoice:)
|
94
|
+
request(
|
95
|
+
path: "compliance/invoices",
|
96
|
+
method: :post,
|
97
|
+
body: {
|
98
|
+
uuid: uuid,
|
99
|
+
invoiceHash: invoice_hash,
|
100
|
+
invoice: invoice
|
101
|
+
}
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Production CSID (Onboarding) API
|
106
|
+
# This endpoint gives you the Base64-encoded certificate back
|
107
|
+
# compliance_request_id is retrieved from the issue_csid request, and is
|
108
|
+
# in the response as responseID
|
109
|
+
def issue_production_csid(compliance_request_id:)
|
110
|
+
request(
|
111
|
+
path: "production/csids",
|
112
|
+
method: :post,
|
113
|
+
body: {compliance_request_id: compliance_request_id}
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Production CSID (Renewal) API
|
118
|
+
# csr stands for Certificate Signing Request
|
119
|
+
# otp stands for One Time Password
|
120
|
+
def renew_production_csid(otp:, csr:)
|
121
|
+
request(
|
122
|
+
path: "production/csids",
|
123
|
+
method: :patch,
|
124
|
+
body: {csr: csr},
|
125
|
+
headers: {"OTP" => otp}
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def request(method:, path:, body: {}, headers: {}, authenticated: true)
|
132
|
+
url = "#{@base_url}/#{path}"
|
133
|
+
headers = default_headers.merge(headers)
|
134
|
+
|
135
|
+
client = if authenticated
|
136
|
+
authenticated_request_cilent
|
137
|
+
else
|
138
|
+
unauthenticated_request_client
|
139
|
+
end
|
140
|
+
|
141
|
+
response = client.send(method, url, json: body, headers: headers)
|
142
|
+
|
143
|
+
response_body = response.body.to_s
|
144
|
+
|
145
|
+
if response.headers["Content-Type"] == "application/json"
|
146
|
+
parse_json_or_return_string(response_body)
|
147
|
+
else
|
148
|
+
response_body
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def authenticated_request_cilent
|
153
|
+
HTTPX.plugin(:basic_authentication).basic_auth(@username, @password)
|
154
|
+
end
|
155
|
+
|
156
|
+
def unauthenticated_request_client
|
157
|
+
HTTPX
|
158
|
+
end
|
159
|
+
|
160
|
+
def default_headers
|
161
|
+
{
|
162
|
+
"Accept-Language" => @language,
|
163
|
+
"Content-Type" => "application/json",
|
164
|
+
"Accept-Version" => @version
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
def parse_json_or_return_string(json)
|
169
|
+
JSON.parse(json)
|
170
|
+
rescue JSON::ParserError
|
171
|
+
json
|
172
|
+
end
|
173
|
+
end
|
data/lib/zatca/hacks.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module ZATCA::Hacks
|
2
|
+
extend self
|
3
|
+
|
4
|
+
# rubocop:disable Layout/HeredocIndentation
|
5
|
+
# rubocop:disable Layout/ClosingHeredocIndentation
|
6
|
+
# ZATCA also hashes serverside to ensure our signed properties hash is correct.
|
7
|
+
# However ZATCA does not format the XML to use the same whitespace needed for
|
8
|
+
# hashing. They generate the hash using the whitespace as you sent it, so to
|
9
|
+
# account for that we need to ensure we use the same exact whitespace as them.
|
10
|
+
#
|
11
|
+
# Due to the way our SDK works, we will sadly not be able to use the same
|
12
|
+
# generated XML, we need to use ZATCA's specific spacing.
|
13
|
+
# So we will generate the entire XML first then replace the qualifying
|
14
|
+
# properties block to account for this.
|
15
|
+
def zatca_indented_qualifying_properties(signing_time:, cert_digest_value:, cert_issuer_name:, cert_serial_number:)
|
16
|
+
<<-XML.chomp
|
17
|
+
<xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="signature">
|
18
|
+
<xades:SignedProperties Id="xadesSignedProperties">
|
19
|
+
<xades:SignedSignatureProperties>
|
20
|
+
<xades:SigningTime>#{signing_time}</xades:SigningTime>
|
21
|
+
<xades:SigningCertificate>
|
22
|
+
<xades:Cert>
|
23
|
+
<xades:CertDigest>
|
24
|
+
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
|
25
|
+
<ds:DigestValue>#{cert_digest_value}</ds:DigestValue>
|
26
|
+
</xades:CertDigest>
|
27
|
+
<xades:IssuerSerial>
|
28
|
+
<ds:X509IssuerName>#{cert_issuer_name}</ds:X509IssuerName>
|
29
|
+
<ds:X509SerialNumber>#{cert_serial_number}</ds:X509SerialNumber>
|
30
|
+
</xades:IssuerSerial>
|
31
|
+
</xades:Cert>
|
32
|
+
</xades:SigningCertificate>
|
33
|
+
</xades:SignedSignatureProperties>
|
34
|
+
</xades:SignedProperties>
|
35
|
+
</xades:QualifyingProperties>
|
36
|
+
XML
|
37
|
+
end
|
38
|
+
|
39
|
+
# rubocop:enable Layout/HeredocIndentation
|
40
|
+
# rubocop:enable Layout/ClosingHeredocIndentation
|
41
|
+
|
42
|
+
def qualifying_properties_regex
|
43
|
+
/[ ]*<xades:QualifyingProperties.*?<\/xades:QualifyingProperties>/m
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ZATCA::Hashing
|
2
|
+
# Returns the content as:
|
3
|
+
# - hash - SHA256 digest (bytes)
|
4
|
+
# - hexdigest - SHA256 digest (hex)
|
5
|
+
# - base64 - SHA256 digest (bytes) then Base64 encoded
|
6
|
+
# - hexdigest_base64 - SHA256 digest (hex) then Base64 encoded
|
7
|
+
def self.generate_hashes(content)
|
8
|
+
sha256 = Digest::SHA256.digest(content)
|
9
|
+
sha256_hex = Digest::SHA256.hexdigest(content)
|
10
|
+
|
11
|
+
{
|
12
|
+
base64: Base64.strict_encode64(sha256),
|
13
|
+
hexdigest_base64: Base64.strict_encode64(sha256_hex),
|
14
|
+
hexdigest: sha256_hex,
|
15
|
+
hash: sha256
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require "base64"
|
3
|
+
|
4
|
+
class ZATCA::QRCodeExtractor
|
5
|
+
attr_reader :invoice_base64
|
6
|
+
|
7
|
+
def initialize(invoice_base64:)
|
8
|
+
@invoice_base64 = invoice_base64
|
9
|
+
end
|
10
|
+
|
11
|
+
def extract
|
12
|
+
xml_invoice = Base64.strict_decode64(invoice_base64)
|
13
|
+
extract_qr_code_base64_from_xml(xml_invoice)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def extract_qr_code_base64_from_xml(xml)
|
19
|
+
# Read Invoice
|
20
|
+
doc = Nokogiri::XML(xml)
|
21
|
+
|
22
|
+
# Extract QR Code by XPath
|
23
|
+
qr_code_node = doc.xpath(qr_code_xpath)&.first
|
24
|
+
|
25
|
+
qr_code_node.present? ? qr_code_node.text : nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def qr_code_xpath
|
29
|
+
"//cac:AdditionalDocumentReference[cbc:ID='QR']/cac:Attachment/cbc:EmbeddedDocumentBinaryObject"
|
30
|
+
end
|
31
|
+
end
|
@@ -2,8 +2,9 @@ require "rqrcode"
|
|
2
2
|
|
3
3
|
module ZATCA
|
4
4
|
class QRCodeGenerator
|
5
|
-
def initialize(tags)
|
5
|
+
def initialize(tags: nil, base64: nil)
|
6
6
|
@tags = tags
|
7
|
+
@base64 = base64
|
7
8
|
end
|
8
9
|
|
9
10
|
def render(size: 256)
|
@@ -15,7 +16,13 @@ module ZATCA
|
|
15
16
|
private
|
16
17
|
|
17
18
|
def generate
|
18
|
-
|
19
|
+
if @tags.present?
|
20
|
+
RQRCode::QRCode.new(@tags.to_base64)
|
21
|
+
elsif @base64.present?
|
22
|
+
RQRCode::QRCode.new(@base64)
|
23
|
+
else
|
24
|
+
raise ArgumentError, "Either tags or base64 must be provided"
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
class ZATCA::Signing::Certificate
|
2
|
+
attr_accessor :serial_number, :issuer_name, :cert_content_without_headers,
|
3
|
+
:hash, :public_key, :public_key_without_headers, :signature,
|
4
|
+
:public_key_bytes
|
5
|
+
|
6
|
+
# Returns the certificate hashed with SHA256 then Base64 encoded
|
7
|
+
def self.generate_base64_hash(base64_certificate)
|
8
|
+
ZATCA::Hashing.generate_hashes(base64_certificate)[:hexdigest_base64]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.read_certificate(certificate_path)
|
12
|
+
certificate = OpenSSL::X509::Certificate.new(File.read(certificate_path))
|
13
|
+
|
14
|
+
new(openssl_certificate: certificate)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(openssl_certificate:)
|
18
|
+
super()
|
19
|
+
|
20
|
+
@serial_number = nil
|
21
|
+
@issuer_name = nil
|
22
|
+
@cert_content_without_headers = nil
|
23
|
+
@hash = nil
|
24
|
+
@public_key = nil
|
25
|
+
@public_key_without_headers = nil
|
26
|
+
@public_key_bytes = nil
|
27
|
+
@signature = nil
|
28
|
+
|
29
|
+
@openssl_certificate = openssl_certificate
|
30
|
+
|
31
|
+
parse_certificate
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :openssl_certificate
|
37
|
+
|
38
|
+
def parse_certificate
|
39
|
+
@cert_content_without_headers = openssl_certificate
|
40
|
+
.to_pem
|
41
|
+
.gsub("-----BEGIN CERTIFICATE-----", "")
|
42
|
+
.gsub("-----END CERTIFICATE-----", "")
|
43
|
+
.delete("\n")
|
44
|
+
|
45
|
+
@hash = self.class.generate_base64_hash(cert_content_without_headers)
|
46
|
+
|
47
|
+
# ZATCA expects the issuer name to have spaces after commas, the issue name
|
48
|
+
# looks like "CN=TSZEINVOICE-SubCA-1,DC=extgazt,DC=gov,DC=local"
|
49
|
+
# but ZATCA wants it to be "CN=TSZEINVOICE-SubCA-1, DC=extgazt, DC=gov, DC=local"
|
50
|
+
@issuer_name = openssl_certificate.issuer.to_utf8.gsub(",", ", ")
|
51
|
+
|
52
|
+
@serial_number = openssl_certificate.serial.to_s
|
53
|
+
@cert_content_without_headers = cert_content_without_headers
|
54
|
+
@public_key = openssl_certificate.public_key.to_pem
|
55
|
+
@public_key_without_headers = @public_key
|
56
|
+
.gsub("-----BEGIN PUBLIC KEY-----", "")
|
57
|
+
.gsub("-----END PUBLIC KEY-----", "")
|
58
|
+
.delete("\n")
|
59
|
+
|
60
|
+
@public_key_bytes = parse_public_key_bytes
|
61
|
+
|
62
|
+
parse_signature
|
63
|
+
end
|
64
|
+
|
65
|
+
def parse_public_key_bytes
|
66
|
+
openssl_certificate.public_key.to_der
|
67
|
+
end
|
68
|
+
|
69
|
+
def parse_signature
|
70
|
+
der = openssl_certificate.to_der
|
71
|
+
asn1 = OpenSSL::ASN1.decode(der)
|
72
|
+
|
73
|
+
# The last element of the ASN1 structure is always the signature
|
74
|
+
# The signature would look like so:
|
75
|
+
# "0F\x02!\x00\xEEa\xD3\xEB(<\xE6;P\x19jw3\xBBOO\xB2d\xDB\xEC\xEC\xBDQ\xC6\xB3v\xD4\xE5\x9E\xD8\x13\xAF\x02!\x00\xFA\xD1\xE6\xD0jf#b\xF7^nqc5\xFCx_\x87h\xA7\xB2\xEC\x10\x11B5+\vcB\x05i"
|
76
|
+
@signature = asn1.value[-1].value
|
77
|
+
end
|
78
|
+
end
|