@@ -49,13 +49,13 @@ public class SysCertManager extends DSNode {
4949 // Constants
5050 // ---------
5151
52- private static final String ALLOW_CLIENTS = "Allow_Anonymous_Clients " ;
53- private static final String ALLOW_SERVERS = "Allow_Anonymous_Servers " ;
54- private static final String VERIFY_HOSTNAMES = "Enable Hostname Verification" ;
52+ private static final String ALLOW_CLIENTS = "Allow Anonymous Clients " ;
53+ private static final String ALLOW_SERVERS = "Allow Anonymous Servers " ;
54+ private static final String VERIFY_HOSTNAMES = "Enable Hostname-Certificate Verification" ;
5555 private static final String HOSTNAME_WHITELIST = "Hostname Whitelist" ;
56- private static final String CERTFILE = "Cert_File " ;
57- private static final String CERTFILE_PASS = "Cert_File_Pass " ;
58- private static final String CERTFILE_TYPE = "Cert_File_Type " ;
56+ private static final String CERTFILE = "Cert File " ;
57+ private static final String CERTFILE_PASS = "Cert File Pass " ;
58+ private static final String CERTFILE_TYPE = "Cert File Type " ;
5959 private static final String LOCAL_TRUSTSTORE = "Local Truststore" ;
6060 private static final String QUARANTINE = "Quarantine" ;
6161 private static final String GENERATE_CSR = "Generate Certificate Signing Request" ;
@@ -372,94 +372,5 @@ public boolean verify(String hostname, SSLSession session) {
372372 }
373373 }
374374 }
375-
376- // private static String generateCSR() {
377- // KeyPairGenerator keyGen;
378- // try {
379- // keyGen = KeyPairGenerator.getInstance("RSA");
380- // } catch (NoSuchAlgorithmException e) {
381- // DSException.throwRuntime(e);
382- // return null;
383- // }
384- // keyGen.initialize(2048, new SecureRandom());
385- // KeyPair pair = keyGen.generateKeyPair();
386- // PKCS10CertificationRequestBuilder p10Builder = new JcaPKCS10CertificationRequestBuilder(
387- // new X500Principal("CN=dslink-java-v2, O=DSA, C=US"), pair.getPublic());
388- // JcaContentSignerBuilder csBuilder = new JcaContentSignerBuilder("SHA256withRSA");
389- // ContentSigner signer;
390- // try {
391- // signer = csBuilder.build(pair.getPrivate());
392- // } catch (OperatorCreationException e) {
393- // DSException.throwRuntime(e);
394- // return null;
395- // }
396- // PKCS10CertificationRequest csr = p10Builder.build(signer);
397- // StringWriter str = new StringWriter();
398- // JcaPEMWriter pemWriter = new JcaPEMWriter(str);
399- // try {
400- // pemWriter.writeObject(csr);
401- // } catch (IOException e) {
402- // DSException.throwRuntime(e);
403- // return null;
404- // } finally {
405- // try {
406- // pemWriter.close();
407- // str.close();
408- // } catch (IOException e) {
409- // DSException.throwRuntime(e);
410- // return null;
411- // }
412- // }
413- // return str.toString();
414- // }
415-
416- // private static X509Certificate generateSelfSigned() {
417- // KeyPairGenerator keyGen;
418- // try {
419- // keyGen = KeyPairGenerator.getInstance("RSA");
420- // } catch (NoSuchAlgorithmException e) {
421- // DSException.throwRuntime(e);
422- // return null;
423- // }
424- // keyGen.initialize(2048, new SecureRandom());
425- // KeyPair pair = keyGen.generateKeyPair();
426- //
427- // Provider bcProvider = new BouncyCastleProvider();
428- // Security.addProvider(bcProvider);
429- //
430- // long now = System.currentTimeMillis();
431- // Date startDate = new Date(now);
432- //
433- // X500Name dname = new X500Name("CN=dslink-java-v2, O=DSA, C=US");
434- // BigInteger certSerialNumber = new BigInteger(Long.toString(now)); // <-- Using the current timestamp as the certificate serial number
435- //
436- // Calendar calendar = Calendar.getInstance();
437- // calendar.setTime(startDate);
438- // calendar.add(Calendar.YEAR, 1); // <-- 1 Yr validity
439- // Date endDate = calendar.getTime();
440- //
441- // String signatureAlgorithm = "SHA256WithRSA"; // <-- Use appropriate signature algorithm based on your keyPair algorithm.
442- //
443- // try {
444- // ContentSigner contentSigner = new JcaContentSignerBuilder(signatureAlgorithm).build(pair.getPrivate());
445- // JcaX509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(dname, certSerialNumber, startDate, endDate, dname, pair.getPublic());
446- //
447- // BasicConstraints basicConstraints = new BasicConstraints(true); // <-- true for CA, false for EndEntity
448- // certBuilder.addExtension(new ASN1ObjectIdentifier("2.5.29.19"), true, basicConstraints); // Basic Constraints is usually marked as critical.
449- //
450- // return new JcaX509CertificateConverter().setProvider(bcProvider).getCertificate(certBuilder.build(contentSigner));
451- // } catch (OperatorCreationException e) {
452- // DSException.throwRuntime(e);
453- // return null;
454- // } catch (CertIOException e) {
455- // DSException.throwRuntime(e);
456- // return null;
457- // } catch (CertificateException e) {
458- // DSException.throwRuntime(e);
459- // return null;
460- // }
461- //
462- //
463- // }
464375
465376}
0 commit comments