Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Traffic Router default certificate configuration for port 443 #7089

@mkrug1981

Description

@mkrug1981

This Improvement request (usability, performance, tech debt, etc.) affects these Traffic Control components:

  • Traffic Router

Current behavior:

Currently it seems not possible to configure the default TLS certificate or use a custom one.

private static HandshakeData createDefaultSsl() {
try {
final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(2048);
final KeyPair keyPair = keyPairGenerator.generateKeyPair();
//Generate self signed certificate
final X509Certificate[] chain = new X509Certificate[1];
// Select provider
Security.addProvider(new BouncyCastleProvider());
// Generate cert details
final long now = System.currentTimeMillis();
final Date startDate = new Date(System.currentTimeMillis());
final X500Name dnName = new X500Name("C=US; ST=CO; L=Denver; " +
"O=Apache Traffic Control; OU=Apache Foundation; OU=Hosted by Traffic Control; " +
"OU=CDNDefault; CN="+DEFAULT_SSL_KEY);
final BigInteger certSerialNumber = new BigInteger(Long.toString(now));
final Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(Calendar.YEAR, 3);
final Date endDate = calendar.getTime();
// Build certificate
final ContentSigner contentSigner = new JcaContentSignerBuilder("SHA1WithRSA").build(keyPair.getPrivate());
final JcaX509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(dnName, certSerialNumber, startDate, endDate, dnName, keyPair.getPublic());
// Attach extensions
certBuilder.addExtension(Extension.basicConstraints, true, new BasicConstraints(true));
certBuilder.addExtension(Extension.keyUsage, true, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment | KeyUsage.keyCertSign));
certBuilder.addExtension(Extension.extendedKeyUsage, true, new ExtendedKeyUsage(new KeyPurposeId[] {
KeyPurposeId.id_kp_clientAuth,
KeyPurposeId.id_kp_serverAuth
}));
// Generate final certificate
final X509CertificateHolder certHolder = certBuilder.build(contentSigner);
final JcaX509CertificateConverter converter = new JcaX509CertificateConverter();
converter.setProvider(new BouncyCastleProvider());
chain[0] = converter.getCertificate(certHolder);
return new HandshakeData(DEFAULT_SSL_KEY, DEFAULT_SSL_KEY, chain, keyPair.getPrivate());
}

It always uses as Example SHA1WithRSA as sigalg. Would be nice to use SHA256WithRSA instead.

Further more it looks like it is unclear how to provide a Default certificate via TO, Following code

// Check to see if a Default cert has been provided by Traffic Ops
if (!master.containsKey(DEFAULT_SSL_KEY)){
// Check to see if a Default cert has been provided/created previously
if (handshakeDataMap.containsKey(DEFAULT_SSL_KEY)) {
master.put(DEFAULT_SSL_KEY, handshakeDataMap.get(DEFAULT_SSL_KEY));
}else{
// create a new default certificate
final HandshakeData defaultHd = createDefaultSsl();
if (defaultHd == null){
log.error("Failed to initialize the CertificateRegistry because of a problem with the 'default' " +
"certificate. Returning the Certificate Registry without a default.");
return;
}
master.put(DEFAULT_SSL_KEY, defaultHd);
}
}

New behavior:

Please make the default certificate configurable or at least allow to set values like sigalg via a configuration file.
Besides it would be nice if a custom default certificate could be used rather than the build in methodology from TR

Metadata

Metadata

Assignees

Labels

improvementThe functionality exists but it could be improved in some way.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions