Skip to content

Commit

Permalink
Edit the Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwertovsky committed Nov 17, 2024
1 parent d591c45 commit 3fc1d78
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ target/
.classpath
.settings/
dependency-reduced-pom.xml

_other/
52 changes: 25 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,39 @@ option key | argument | default | description
--cert-file | text | | Insurer certificate on disk (DER or Base64 with boundaries). The program looks for keys according this certificate
--pkcs-library | file | | Path to PKCS library

Write certificate on token:

## Sign file with private key in PKCS#12 container on disk
```
pkcs11-tool --module /usr/lib/librtpkcs11ecp.so --type cert --login --write-object test.pem --id 74657374
java -jar gost_sign.jar -i file.pdf --pfx-file private.pfx --pfx-alias test
```

Make DER certificate from PEM:
## Create PFX container
```
java -jar gost_sign.jar --pfx-create --pfx-alias test --key-file private.key --cert-chain private.crt --cert-chain issuer.crt --cert-chain root.crt --pfx-file output.pfx
```
Options:
option key | argument | default | description
---|---|---|---
--pfx-create | | | Create pfx container. Try --pfx-create --help
--key-file | file | | Private key file
--cert-chain | file | | Certificate chain files (DER or Base64 with boundaries). Option may be defined more than once. The first is public certificate for private key.
--pfx-alias | text | | Key alias in pfx store
--pfx-file | file | | PFX key store file

## Verify signature
```
openssl x509 -in certificate.pem -out certificate.der -outform DER
java -jar gost_sign.jar --verify -i file.pdf --sig-file file.pdf.sig
```

## Add signature to PDF document
```
java -jar gost_sign.jar -i file.pdf --pkcs-id test --pkcs-library /usr/lib/librtpkcs11ecp.so --pdf --pdf-visual --pdf-position-x 100 --pdf-position-y 100
```

PDf options:
PDF options:
option key | argument | default | description
---|---|---|---
--pdf | | | Signatue is inside pdf file
--pdf | | | Signature is inside pdf file
--pdf-visual | | | Make visual field for sign. Text data from certificate or use your image
--pdf-page | number | 1 |Page for sign visualization. The fist page is 1
--pdf-position-x | number | error | Horizontal position on page in pixels
Expand All @@ -55,38 +67,24 @@ option key | argument | default | description
--location | | | PDF sign attribute
--reason | | | PDF sign attribute

## Verify pdf

## Sign file with private key in PKCS#12 container on disk
If the signature is inside PDF.
```
java -jar gost_sign.jar -i file.pdf --pfx-file private.pfx --pfx-alias test
java -jar gost_sign.jar --verify -i file.pdf --pdf
```

## Create PFX container
```
java -jar gost_sign.jar --pfx-create --pfx-alias test --key-file private.key --cert-chain private.crt --cert-chain issuer.crt --cert-chain root.crt --pfx-file output.pfx
```
Options:
option key | argument | default | description
---|---|---|---
--pfx-create | | | Create pfx container. Try --pfx-create --help
--key-file | file | | Private key file
--cert-chain | file | | Certificate chain files (DER or Base64 with boundaries). Option may be defined more than once. The first is public certificate for private key.
--pfx-alias | text | | Key alias in pfx store
--pfx-file | file | | PFX key store file
## Write certificate on token:

## Verify signature
```
java -jar gost_sign.jar --verify -i file.pdf --sig-file file.pdf.sig
pkcs11-tool --module /usr/lib/librtpkcs11ecp.so --type cert --login --write-object test.pem --id 74657374
```

## Verify pdf
## Make DER certificate from PEM:

If the signature is inside PDF.
```
java -jar gost_sign.jar --verify -i file.pdf --pdf
openssl x509 -in certificate.pem -out certificate.der -outform DER
```





2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.qwertovsky</groupId>
<artifactId>gost_sign</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down

0 comments on commit 3fc1d78

Please sign in to comment.