...
Test code for running cmpv2 client against EJBCA server through unit test
Code Block |
---|
@Test public void testServerWithRealUrl() throws CmpClientException { setValidCsrMetaValuesAndDateValues(); csrMeta.externalCaUrlcaUrl("http://127.0.0.1/ejbca/publicweb/cmp/cmpRAcmpSubRA"); csrMeta.password("mypassword"); CmpClientImpl cmpClient = new CmpClientImpl(HttpClients.createDefault()); try { cmpClient.createCertRequestcreateCertificate("data", "RA", csrMeta, cert, notBefore, notAfter); } catch (CAOfflineException e) { e.printStackTrace(); } ", "RA", csrMeta, cert, notBefore, notAfter); } private void setValidCsrMetaValuesAndDateValues() { ArrayList<RDN> rdns = new ArrayList<>(); try { rdns.add(new RDN("O=CommonCompany")); } catch (CertException e) { e.printStackTrace(); } csrMeta = new CSRMeta(rdns); csrMeta.cn("Node123CN=CommonName"); csrMeta.san("CommonName.com"); csrMeta.password("password"); ; csrMeta.email("CommonName@cn.com"); csrMeta.issuerCn("CN=ManagementCA"); when(kpg.generateKeyPair()).thenReturn(keyPair); csrMeta.keypair(trans); csrMeta.externalCaUrlcaUrl("http://127.0.0.1/ejbca/publicweb/cmp/cmpRAcmp"); try { try {notBefore = notBefore = Optional.ofNullable(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2019/11/11 12:00:00")); notAfter = notAfter = Optional.ofNullable(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2020/11/11 12:00:00")); } catch (ParseException e) { e.printStackTrace(); } } |
Usage
Docker
Run CertService as docker via following command: TBA
...