Giter Site home page Giter Site logo

Comments (3)

mskalski avatar mskalski commented on August 17, 2024

Two notes:

# Open a session on our token
with token.open(user_pin='***', rw=True) as session:
    # Generate an RSA keypair in this session
    pub, priv = session.generate_keypair(pkcs11.KeyType.RSA, 2048)

# Extract public key
key = session.get_key(key_type=KeyType.RSA, object_class=ObjectClass.PUBLIC_KEY)

When using with scope, after scope ends opened session is closed, hence the error pkcs11.exceptions.SessionHandleInvalid - you are using session which was closed for subsequent session.get_key() function.

The behaviour here of opensc PKCS#11 library is completely correct.

And You are creating session (in memory only) public key pair, because of lack store=True parameter in session.generate_keypair() function, so they won't be stored on token and won't be accessible after session will be closed. Is it intentional?

from python-pkcs11.

mskalski avatar mskalski commented on August 17, 2024

PS Sorry for first comment, edited it accordingly

from python-pkcs11.

robertocal avatar robertocal commented on August 17, 2024

No, it was not intentional. Thank you for the clarification.

from python-pkcs11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.