0

The documentation at this page states that

Any value may be set using the corresponding set<Value> method.

However, I am not sure how to interpret this statement. I have tried the following but none of them compile, and nor did I expect them to.

certificate.set3();
certificate.setThree();
serverCertificate.set<3>();

What is the correct method call to set the version number explicitly?

merlin2011
  • 71,677
  • 44
  • 195
  • 329

1 Answers1

1

You can not. It explicitely says:

This class represents a X.509 version 3 certificate, as specified by ISO/IEC and ANSI X9.

Update: Seems that you can not actually set the version. It "configures" itself the proper version depending on which extensions you use. In V1 there were no extensions and in V2 just few.

The version number per default is set to 1 indicating a Version 1 certificate. When including subjectUniqueID or issuerUniqueID, the version automatically will be set to 2, and when adding an extension increased to 3.

Cratylus
  • 52,998
  • 69
  • 209
  • 339
  • If it is version 3, why does it have `The version number per default is set to 1 indicating a Version 1 certificate`? – merlin2011 Mar 11 '13 at 19:58
  • You removed the line from doc in my question though. – merlin2011 Mar 11 '13 at 20:07
  • `Any value may be set using the corresponding set method. The version number per default is set to 1 indicating a Version 1 certificate.` I am trying to figure out the "set" method it is referring to. – merlin2011 Mar 11 '13 at 20:07
  • I believe that this line refers to other properties and not the version number.I haven't used `IAIK` but BC and there you can set the version.From this doc it appears that you can not but perhaps it is better since it figures out by itself what version to use. – Cratylus Mar 11 '13 at 20:09