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

src/openssl.c: Add attributes methods on x509.csr #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

telent
Copy link

@telent telent commented Sep 25, 2024

What does it do?

Add methods on CSR to deal with attributes

getAttribute(name, startpos=-1) =>
  (first attribute with that name after startpos) and pos as multiple values
    
getAttributeTypes() => list of all the attribute names
    
addAttribute(name, values, type = MBSTRING_ASC)
  values is an array of strings
  type (if supplied) is numeric, one of MBSTRING_ASC, MBSTRING_UTF8 etc

  only stringish types are implemented

deleteAttribute(pos)
  deletes the attribute at position pos (as returned by getAttribute) 

This is submitted for feedback not for merge yet. Obvious warts

  • only supports attributes with string types (although this is probably 95% of practical uses for attributes, maybe this is not a big deal)
  • to specify a type other than MBSTRING_ASC you need to look up its value in openssl header files

I would welcome any and all comment/criticism about api design, coding standards, etc etc

Why is is useful?

My use case for this is that I want a program that replicates the Puppet CA "policy based keysigning" functionality. The client generates a CSR with a pre-shared key embedded, and submits it for signing using an API: the API server checks for that PSK and decides whether or not to sign it. The convention seems to be to use the challengePassword custom attribute for this purpose, so I needed a way of getting to it.

getAttribute(name, startpos=-1) =>
 (first attribute with that name after startpos) and pos as multiple values

getAttributeTypes() => list of all the attribute names

addAttribute(name, values, type = MBSTRING_ASC)
  values is an array
  type is one of MBSTRING_ASC, MBSTRING_UTF8 etc

  only stringish types are implemented
@telent telent changed the title src/openssl.c: Add getAttributes method on x509.csr src/openssl.c: Add attributes methods on x509.csr Sep 30, 2024
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

Successfully merging this pull request may close these issues.

1 participant