-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new sequential number generator: legacy2
The current generator has a problem with converting from hex to decimal the range boundaries creating gaps between ranges. This a problem when third parties tools are used to with certificates because contiguous range are expected. This commit introduce the generator legacy2. This uses same configuration parameter but hex value are specified by the prefix '0x'. When value are written to the configuration value it is possible to set the radix with the options: - dbs.cert.id.radix (default to 16) - dbs.key.id.radix (default to 16) - dbs.request.id.radix (default to 10) Additionally, the new command `pki-server <subsystem>-id-generator-*` has been added to migrate from the legacy generator to the legacy2 or to random.
- Loading branch information
Showing
27 changed files
with
1,053 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
base/ca/src/main/java/org/dogtagpki/server/ca/cli/CAIdCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca.cli; | ||
|
||
import org.dogtagpki.cli.CLI; | ||
|
||
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CAIdCLI extends CLI { | ||
public CAIdCLI(CLI parent) { | ||
super("id", "CA id generator management commands", parent); | ||
|
||
addModule(new CAIdGeneratorCLI(this)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
base/ca/src/main/java/org/dogtagpki/server/ca/cli/CAIdGeneratorCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca.cli; | ||
|
||
import org.dogtagpki.cli.CLI; | ||
|
||
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CAIdGeneratorCLI extends CLI { | ||
|
||
public CAIdGeneratorCLI(CLI parent) { | ||
super("generator", "CA id generator commands", parent); | ||
|
||
addModule(new CAIdGeneratorUpdateCLI(this)); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
base/ca/src/main/java/org/dogtagpki/server/ca/cli/CAIdGeneratorUpdateCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca.cli; | ||
|
||
import com.netscape.cmscore.apps.DatabaseConfig; | ||
import com.netscape.cmscore.dbs.CertificateRepository; | ||
import com.netscape.cmscore.dbs.Repository; | ||
import com.netscape.cmscore.dbs.Repository.IDGenerator; | ||
import com.netscape.cmscore.ldapconn.LdapAuthInfo; | ||
import com.netscape.cmscore.ldapconn.LdapConnInfo; | ||
import com.netscape.cmscore.ldapconn.PKISocketFactory; | ||
import org.dogtagpki.cli.CLI; | ||
import org.dogtagpki.server.cli.SubsystemIdGeneratorUpdateCLI; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CAIdGeneratorUpdateCLI extends SubsystemIdGeneratorUpdateCLI { | ||
private static final Logger logger = LoggerFactory.getLogger(CAIdGeneratorUpdateCLI.class); | ||
|
||
public CAIdGeneratorUpdateCLI(CLI parent) { | ||
super(parent); | ||
} | ||
|
||
@Override | ||
protected void updateSerialNumberRangeGenerator(PKISocketFactory socketFactory, LdapConnInfo connInfo, | ||
LdapAuthInfo authInfo, DatabaseConfig dbConfig, String baseDN, IDGenerator newGenerator, String hostName, String securePort) throws Exception { | ||
String value = dbConfig.getString( | ||
CertificateRepository.PROP_CERT_ID_GENERATOR, | ||
CertificateRepository.DEFAULT_CERT_ID_GENERATOR); | ||
idGenerator = IDGenerator.fromString(value); | ||
|
||
if (newGenerator == IDGenerator.RANDOM && idGenerator != IDGenerator.RANDOM) { | ||
dbConfig.put(CertificateRepository.PROP_CERT_ID_GENERATOR, newGenerator.toString()); | ||
dbConfig.put(CertificateRepository.PROP_CERT_ID_LENGTH, "128"); | ||
dbConfig.remove("enableRandomSerialNumbers"); | ||
dbConfig.remove("randomSerialNumberCounter"); | ||
} | ||
if (newGenerator == IDGenerator.LEGACY_2 && idGenerator == IDGenerator.LEGACY) { | ||
dbConfig.put(CertificateRepository.PROP_CERT_ID_GENERATOR, newGenerator.toString()); | ||
dbConfig.put(CertificateRepository.PROP_CERT_ID_RADIX, Integer.toString(Repository.HEX)); | ||
} | ||
|
||
super.updateSerialNumberRangeGenerator(socketFactory, connInfo, authInfo, dbConfig, baseDN, newGenerator, hostName, securePort); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.