Skip to content

Xades signature sign and verification sample code for Thailand etax invoice

Notifications You must be signed in to change notification settings

kentreez/etax-xades

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Xades

This repository is Xades signature sign and verification sample code for Thailand etax invoice

XadesBesSignByParametersMain : Parameters

input xml filepath
output xml filepath
method PKCS11
driver /usr/lib/libeToken.so
token label getting from: pkcs11-tool --module /usr/lib/libeToken.so --list-slots
slot number getting from: pkcs11-tool --module /usr/lib/libeToken.so --list-slots
certificate serial run below shell script to get list of serial
token password
#!/bin/sh

# Check if $1 is set
if [ -z "$1" ]; then
    echo "Error: Slot is not set."
    echo "Usage: $0 <slot>"
    exit 1  # Exit with a non-zero status code indicating an error
fi

# Check if $1 is an integer
if ! [ "$1" -eq "$1" ] 2>/dev/null; then
    echo "Error: Slot is not an integer."
    exit 1
fi

lines=$( pkcs11-tool --module /usr/lib/libeToken.so --list-objects --type cert --slot $1 | awk '/label:/ || /subject:/ {if (/label:/) {printf "%s!",$2} else {gsub(/.*CN=/, ""); print}}' )

echo "$lines" | while IFS= read -r line; do
  label=$(echo "$line" | cut -d'!' -f1)
  CN=$(echo "$line" | cut -d'!' -f2)
  echo $CN | sed 's/\\x//g' | xxd -r -p
  echo ''
  pkcs11-tool --module /usr/lib/libeToken.so --slot 0 --read-object --type cert --label ${label} | openssl x509 -inform DER -noout -serial -enddate
  echo '---------------------------------'
done

About

Xades signature sign and verification sample code for Thailand etax invoice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%