From 99e778f9ae7b2d8f947d8e224068ae26dd6401fc Mon Sep 17 00:00:00 2001 From: "Crystal.Sea" Date: Thu, 3 Sep 2020 21:50:56 +0800 Subject: [PATCH] run @Test --- .../org/maxkey/crypto/cert/X509V3CertGenTest.java | 12 +++++++++--- .../src/test/resources/spring/applicationContext.xml | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java index cd22c4108..5cc42df2f 100644 --- a/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java +++ b/maxkey-core/src/test/java/org/maxkey/crypto/cert/X509V3CertGenTest.java @@ -17,6 +17,7 @@ package org.maxkey.crypto.cert; +import java.io.File; import java.io.FileOutputStream; import java.security.KeyPair; import java.security.Security; @@ -33,15 +34,20 @@ public class X509V3CertGenTest { public void generateV3() throws Exception { Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); KeyPair keyPair =X509V3CertGen.genRSAKeyPair(); - String issuer="CN=connsec.com,O=connsec,L=SH,ST=SH,C=CN"; + String issuer="CN=maxkey.top,O=maxkey,L=SH,ST=SH,C=CN"; Date startDate=DateTime.now().toDate(); Date endDate=DateTime.now().plusMonths(10).toDate(); System.out.println("Private : "+ keyPair.getPrivate().toString()); System.out.println("Public : "+ keyPair.getPublic().toString()); X509Certificate cert = X509V3CertGen.genV3Certificate(issuer,issuer,startDate,endDate,keyPair); - - FileOutputStream out = new FileOutputStream("c:\\Cert345.cer"); + String certFileString = "D:\\MaxKey\\Workspaces\\maxkey\\Cert345.cer"; + File certFile =new File(certFileString); + if(certFile.exists()) { + certFile.deleteOnExit(); + } + + FileOutputStream out = new FileOutputStream(certFileString); out.write(cert.getEncoded()); out.close(); diff --git a/maxkey-persistence/src/test/resources/spring/applicationContext.xml b/maxkey-persistence/src/test/resources/spring/applicationContext.xml index 3dbc04a49..8813a3b27 100644 --- a/maxkey-persistence/src/test/resources/spring/applicationContext.xml +++ b/maxkey-persistence/src/test/resources/spring/applicationContext.xml @@ -52,6 +52,10 @@ + + + + -- GitLab