Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with "pkcs11.h" when running with "go build", "go run ." or "go run main.go" #175

Open
Victor7k opened this issue Nov 7, 2023 · 0 comments

Comments

@Victor7k
Copy link

Victor7k commented Nov 7, 2023

I'm writing a CGO code on Windows 10 but after I solved an error another one took place and I don't know what it is, how it happened or how to solve it. Someone knows how to fix it?

package main

import (
    "fmt"

    "github.com/miekg/pkcs11"
)

func main() {
    p := pkcs11.New("aetpkss1.dll")
    err := p.Initialize()

    if err != nil {
        panic(err)
    }

    defer p.Destroy()
    defer p.Finalize()

    slots, err := p.GetSlotList(true)
    if err != nil {
        panic(err)
    }

    session, err := p.OpenSession(slots[0], pkcs11.CKF_SERIAL_SESSION|pkcs11.CKF_RW_SESSION)
    if err != nil {
        panic(err)
    }
    defer p.CloseSession(session)

    err = p.Login(session, pkcs11.CKU_USER, "1234")
    if err != nil {
        panic(err)
    }
    defer p.Logout(session)

    p.DigestInit(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_SHA_1, nil)})
    hash, err := p.Digest(session, []byte("this is a string"))
    if err != nil {
        panic(err)
    }

    for _, d := range hash {
        fmt.Printf("%x", d)
    }

    fmt.Println()
}
C:\Users\user\Desktop\Teste2> go run main.go
# runtime/cgo
cc1.exe: error: C:\src\github.com\miekg\pkcs11\pkcs11.h: not a directory [-Werror]
cc1.exe: all warnings being treated as errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant