Fix linting errors

This commit is contained in:
Paul van Brouwershaven
2024-11-14 13:33:46 +01:00
parent 7946d5266d
commit bacc810a68
12 changed files with 32 additions and 108 deletions

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/digitorus/pdfsign
go 1.17
go 1.22
require (
github.com/digitorus/pdf v0.1.2

62
go.sum
View File

@@ -5,71 +5,9 @@ github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 h1:ge14PCmCvPjpMQM
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352/go.mod h1:SKVExuS+vpu2l9IoOc0RwqE7NYnb0JlcFHFnEJkVDzc=
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 h1:lxmTCgmHE1GUYL7P0MlNa00M67axePTq+9nBSGddR8I=
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7/go.mod h1:GvWntX9qiTlOud0WkQ6ewFm0LPy5JUR1Xo0Ngbd1w6Y=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/mattetti/filebuffer v1.0.1 h1:gG7pyfnSIZCxdoKq+cPa8T0hhYtD9NxCdI4D7PTjRLM=
github.com/mattetti/filebuffer v1.0.1/go.mod h1:YdMURNDOttIiruleeVr6f56OrMc+MydEnTcXwtkxNVs=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@@ -34,7 +34,7 @@ func (r *InfoArchival) AddOCSP(b []byte) error {
// true if the certificate is marked as revoked.
//
// TODO: We should report if there is no CRL or OCSP response embedded for this certificate
// TODO: Information about the revocation (time, reason, etc) must be extractable
// TODO: Information about the revocation (time, reason, etc) must be extractable.
func (r *InfoArchival) IsRevoked(c *x509.Certificate) bool {
// check the crl and ocsp to see if this certificate is revoked
return true
@@ -45,10 +45,10 @@ func (r *InfoArchival) IsRevoked(c *x509.Certificate) bool {
type CRL []asn1.RawValue
// OCSP contains the raw bytes of an OCSP response and can be parsed with
// x/crypto/ocsp.ParseResponse
// x/crypto/ocsp.ParseResponse.
type OCSP []asn1.RawValue
// ANS.1 Object OtherRevInfo
// ANS.1 Object OtherRevInfo.
type Other struct {
Type asn1.ObjectIdentifier
Value []byte

View File

@@ -11,7 +11,6 @@ import (
"time"
"github.com/digitorus/pdf"
"golang.org/x/text/encoding/unicode"
"golang.org/x/text/transform"
)
@@ -19,7 +18,6 @@ import (
func findFirstPage(parent pdf.Value) (pdf.Value, error) {
value_type := parent.Key("Type").String()
if value_type == "/Pages" {
for i := 0; i < parent.Key("Kids").Len(); i++ {
recurse_parent, recurse_err := findFirstPage(parent.Key("Kids").Index(i))
if recurse_err == nil {

View File

@@ -25,7 +25,8 @@ var testFiles = []struct {
expectedCatalogs: map[CertType]string{
CertificationSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 3 >> >>\nendobj\n",
UsageRightsSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 1 >> >>\nendobj\n",
ApprovalSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 3 >> >>\nendobj\n"},
ApprovalSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 3 >> >>\nendobj\n",
},
},
}

View File

@@ -43,7 +43,6 @@ func (context *SignContext) createSignaturePlaceholder() (dssd string, byte_rang
signature_buffer.Write(bytes.Repeat([]byte("0"), int(context.SignatureMaxLength)))
signature_buffer.WriteString(">\n")
//if context.SignData.Signature.CertType != ApprovalSignature {
switch context.SignData.Signature.CertType {
case CertificationSignature, UsageRightsSignature:
signature_buffer.WriteString(" /Reference [\n") // start array of signature reference dictionaries
@@ -51,7 +50,6 @@ func (context *SignContext) createSignaturePlaceholder() (dssd string, byte_rang
}
switch context.SignData.Signature.CertType {
// Certification signature (also known as an author signature)
case CertificationSignature:
signature_buffer.WriteString(" /TransformMethod /DocMDP\n")

View File

@@ -7,7 +7,7 @@ import (
"github.com/digitorus/pdf"
)
// Define annotation flag constants
// Define annotation flag constants.
const (
AnnotationFlagInvisible = 1 << 0
AnnotationFlagHidden = 1 << 1
@@ -78,7 +78,7 @@ func (context *SignContext) createVisualSignature(visible bool, pageNumber int,
}
// Define the annotation flags for the signature field (132)
//annotationFlags := AnnotationFlagPrint | AnnotationFlagNoZoom | AnnotationFlagNoRotate | AnnotationFlagReadOnly | AnnotationFlagLockedContents
// annotationFlags := AnnotationFlagPrint | AnnotationFlagNoZoom | AnnotationFlagNoRotate | AnnotationFlagReadOnly | AnnotationFlagLockedContents
visual_signature += fmt.Sprintf(" /F %d", 132)
// Define the field type as a signature.
visual_signature += " /FT /Sig"
@@ -104,7 +104,7 @@ func (context *SignContext) createVisualSignature(visible bool, pageNumber int,
return visual_signature, nil
}
// Helper function to find a page by its number
// Helper function to find a page by its number.
func findPageByNumber(pages pdf.Value, pageNumber int) (pdf.Value, error) {
if pages.Key("Type").Name() == "Pages" {
kids := pages.Key("Kids")

View File

@@ -32,6 +32,8 @@ func (context *SignContext) writeXref() error {
}
// writeXrefTable writes the cross-reference table to the output buffer.
//
//nolint:unused
func (context *SignContext) writeXrefTable() error {
// Seek to the start of the xref table
if _, err := context.InputFile.Seek(context.PDFReader.XrefInformation.StartPos, io.SeekStart); err != nil {

View File

@@ -9,7 +9,6 @@ import (
"strings"
"github.com/digitorus/pdfsign/revocation"
"golang.org/x/crypto/ocsp"
)

View File

@@ -12,7 +12,6 @@ import (
"github.com/digitorus/pdf"
"github.com/digitorus/pdfsign/revocation"
"github.com/digitorus/pkcs7"
"github.com/mattetti/filebuffer"
)
@@ -202,7 +201,6 @@ func (context *SignContext) SignPDF() error {
// If not a timestamp signature
if context.SignData.Signature.CertType != TimeStampSignature {
switch context.SignData.Certificate.SignatureAlgorithm.String() {
case "SHA1-RSA":
case "ECDSA-SHA1":
@@ -268,7 +266,7 @@ func (context *SignContext) SignPDF() error {
}
// Create visual signature (visible or invisible based on CertType)
//visible := context.SignData.Signature.CertType == CertificationSignature
// visible := context.SignData.Signature.CertType == CertificationSignature
// Example usage: passing page number and default rect values
visual_signature, err := context.createVisualSignature(false, 1, [4]float64{0, 0, 0, 0})
if err != nil {

View File

@@ -15,7 +15,6 @@ import (
"github.com/digitorus/pdf"
"github.com/digitorus/pdfsign/revocation"
"github.com/digitorus/pdfsign/verify"
"github.com/mattetti/filebuffer"
)
@@ -124,7 +123,7 @@ func TestReaderCanReadPDF(t *testing.T) {
func TestSignPDF(t *testing.T) {
_ = os.RemoveAll("../testfiles/failed/")
_ = os.MkdirAll("../testfiles/failed/", 0777)
_ = os.MkdirAll("../testfiles/failed/", 0o777)
files, err := os.ReadDir("../testfiles/")
if err != nil {
@@ -169,7 +168,6 @@ func TestSignPDF(t *testing.T) {
RevocationData: revocation.InfoArchival{},
RevocationFunction: DefaultEmbedRevocationStatusFunction,
})
if err != nil {
st.Fatalf("%s: %s", f.Name(), err.Error())
}
@@ -209,7 +207,6 @@ func TestSignPDFFileUTF8(t *testing.T) {
Signer: pkey,
Certificate: cert,
})
if err != nil {
t.Fatalf("%s: %s", originalFileName, err.Error())
}
@@ -269,7 +266,6 @@ func BenchmarkSignPDF(b *testing.B) {
CertificateChains: certificateChains,
RevocationData: revocation.InfoArchival{},
})
if err != nil {
b.Fatalf("%s: %s", "testfile20.pdf", err.Error())
}
@@ -305,7 +301,6 @@ func TestSignPDFWithTwoApproval(t *testing.T) {
Signer: pkey,
Certificate: cert,
})
if err != nil {
t.Fatalf("%s: %s", "testfile20.pdf", err.Error())
}
@@ -343,7 +338,6 @@ func TestSignPDFWithCertificationApprovalAndTimeStamp(t *testing.T) {
Signer: pkey,
Certificate: cert,
})
if err != nil {
t.Fatalf("%s: %s", filepath.Base(tbsFile), err.Error())
}
@@ -376,7 +370,6 @@ func TestSignPDFWithCertificationApprovalAndTimeStamp(t *testing.T) {
Signer: pkey,
Certificate: cert,
})
if err != nil {
t.Fatalf("%s: %s", filepath.Base(tbsFile), err.Error())
}
@@ -426,7 +419,6 @@ func TestTimestampPDFFile(t *testing.T) {
URL: "http://timestamp.entrust.net/TSS/RFC3161sha2TS",
},
})
if err != nil {
t.Fatalf("%s: %s", "testfile20.pdf", err.Error())
}

View File

@@ -9,17 +9,14 @@ import (
"io"
"os"
"reflect"
"strconv"
"strings"
"time"
"github.com/digitorus/pdf"
"github.com/digitorus/pdfsign/revocation"
"github.com/digitorus/pkcs7"
"github.com/digitorus/timestamp"
"strconv"
"strings"
"golang.org/x/crypto/ocsp"
)
@@ -51,7 +48,7 @@ type Certificate struct {
CRLEmbedded bool `json:"crl_embedded"`
}
// DocumentInfo contains document information
// DocumentInfo contains document information.
type DocumentInfo struct {
Author string `json:"author"`
Creator string `json:"creator"`
@@ -128,7 +125,7 @@ func Reader(file io.ReaderAt, size int64) (apiResp *Response, err error) {
// digest is computed. (See 7.3.4, “String Objects“)
p7, err := pkcs7.Parse([]byte(v.Key("Contents").RawString()))
if err != nil {
//fmt.Println(err)
// fmt.Println(err)
continue
}
@@ -156,11 +153,11 @@ func Reader(file io.ReaderAt, size int64) (apiResp *Response, err error) {
// Signer certificate
// http://www.alvestrand.no/objectid/1.2.840.113549.1.9.html
// http://www.alvestrand.no/objectid/1.2.840.113583.1.1.8.html
//var isn []byte
// var isn []byte
for _, s := range p7.Signers {
//isn = s.IssuerAndSerialNumber.IssuerName.FullBytes
//for _, a := range s.AuthenticatedAttributes {
//fmt.Printf("A: %v, %#v\n", s.IssuerAndSerialNumber.SerialNumber, a.Type)
// isn = s.IssuerAndSerialNumber.IssuerName.FullBytes
// for _, a := range s.AuthenticatedAttributes {
// fmt.Printf("A: %v, %#v\n", s.IssuerAndSerialNumber.SerialNumber, a.Type)
//}
// Timestamp
@@ -168,10 +165,10 @@ func Reader(file io.ReaderAt, size int64) (apiResp *Response, err error) {
// Timestamp
// 1.2.840.113549.1.9.16.2.14 - RFC 3161 id-aa-timeStampToken
for _, attr := range s.UnauthenticatedAttributes {
//fmt.Printf("U: %v, %#v\n", s.IssuerAndSerialNumber.SerialNumber, attr.Type)
// fmt.Printf("U: %v, %#v\n", s.IssuerAndSerialNumber.SerialNumber, attr.Type)
if attr.Type.Equal(asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 16, 2, 14}) {
//fmt.Println("Found timestamp")
// fmt.Println("Found timestamp")
signer.TimeStamp, err = timestamp.Parse(attr.Value.Bytes)
if err != nil {
@@ -225,7 +222,7 @@ func Reader(file io.ReaderAt, size int64) (apiResp *Response, err error) {
_ = p7.UnmarshalSignedAttribute(asn1.ObjectIdentifier{1, 2, 840, 113583, 1, 1, 8}, &revInfo)
// Parse OCSP response
var ocspStatus = make(map[string]*ocsp.Response)
ocspStatus := make(map[string]*ocsp.Response)
for _, o := range revInfo.OCSP {
resp, err := ocsp.ParseResponse(o.FullBytes, nil)
if err != nil {
@@ -246,7 +243,6 @@ func Reader(file io.ReaderAt, size int64) (apiResp *Response, err error) {
CurrentTime: cert.NotBefore,
KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageAny},
})
if err != nil {
c.VerifyError = err.Error()
}
@@ -316,7 +312,7 @@ func Reader(file io.ReaderAt, size int64) (apiResp *Response, err error) {
// If SubFilter is adbe.pkcs7.detached or adbe.pkcs7.sha1, this entry
// shall not be used, and the certificate chain shall be put in the PKCS#7
// envelope in Contents.
//v.Key("Cert").Text()
// v.Key("Cert").Text()
apiResp.Signers = append(apiResp.Signers, signer)
}
@@ -330,10 +326,12 @@ func Reader(file io.ReaderAt, size int64) (apiResp *Response, err error) {
return
}
// parseDocumentInfo parses document information
// parseDocumentInfo parses document information.
func parseDocumentInfo(v pdf.Value, documentInfo *DocumentInfo) {
keys := []string{"Author", "CreationDate", "Creator", "Hash", "Keywords", "ModDate",
"Name", "Pages", "Permission", "Producer", "Subject", "Title"}
keys := []string{
"Author", "CreationDate", "Creator", "Hash", "Keywords", "ModDate",
"Name", "Pages", "Permission", "Producer", "Subject", "Title",
}
for _, key := range keys {
value := v.Key(key)
@@ -363,7 +361,7 @@ func parseDocumentInfo(v pdf.Value, documentInfo *DocumentInfo) {
}
}
// parseDate parses pdf formatted dates
// parseDate parses pdf formatted dates.
func parseDate(v string) (time.Time, error) {
// PDF Date Format
// (D:YYYYMMDDHHmmSSOHH'mm')
@@ -385,7 +383,7 @@ func parseDate(v string) (time.Time, error) {
return time.Parse("D:20060102150405Z07'00'", v)
}
// parseKeywords parses keywords pdf meta data
// parseKeywords parses keywords pdf meta data.
func parseKeywords(value string) []string {
// keywords must be separated by commas or semicolons or could be just separated with spaces, after the semicolon could be a space
// https://stackoverflow.com/questions/44608608/the-separator-between-keywords-in-pdf-meta-data