Search code examples
javacertificatebouncycastle

Is there a way to name or identify a DERSequence with a String?


Just as the question states. With the use of the BouncyCastle library I'm trying to build a number of sequences that contain an x amount of UTF8Strings within them. I have another piece of code that queries the extension (within which this structure is built) for the length of each of the nested Sequences to see how many UTF8Strings are stored within, however I don't specifically know a way to name a DERSequence which is stopping me from getting that number of stored UTF8Strings, and the documentation is rather hard to read. The structure looks something like below:

DERSequence Seq1
  DERSequence Seq11
    UTF8String(string1)
  DERSequence Seq12
    UTF8String(string2)
    UTF8String(string3)
  DERSequence Seq13
    UTF8String(string4)
    UTF8String(string5)

Is there a way to identify DERSequences with a string (in the example they are "Seq11", "Seq12", "Seq13") or can I use another class that I can identify the specific sequence and take their value?


Solution

  • After a number of terrible hours, I found that the best option is to setup the other code to read the sequences in a specific order, as opposed to watch for user error. It's not a foolproof solution but it's the best we've managed to setup and it works well enough.