import java.util.Base64;
import java.util.Date;
import java.util.Properties;
+import java.util.Random;
import javax.net.ssl.SSLSocketFactory;
public class TestSendmail extends ConfiguredTest {
+ private static final Random rng = new Random();
+
@Test
public void testSendmail() throws IOException, GeneralSecurityException {
initSelfsign();
X509CertInfo info = new X509CertInfo();
// Add all mandatory attributes
info.set(X509CertInfo.VERSION, new CertificateVersion(CertificateVersion.V3));
- info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(new java.util.Random().nextInt() & 0x7fffffff));
+ info.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(rng.nextInt() & 0x7fffffff));
AlgorithmId algID = AlgorithmId.get("SHA256WithRSA");
info.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(algID));
info.set(X509CertInfo.SUBJECT, new X500Name("EMAIL=system@cacert.org"));
public static void clearCaches() throws IOException {
ObjectCache.clearAllCaches();
- String type = testProps.getProperty("type");
+ // String type = testProps.getProperty("type");
URL u = new URL("https://" + getServerName() + "/manage");
u.openConnection().getHeaderField("Location");
}
@After
public void clearAcceptLanguage() {
- acceptLanguage = null;
+ ManagedTest.setAcceptLanguage(null);
}
public TestMail waitForMail() {
- try {
- return ter.recieve();
- } catch (InterruptedException e) {
- throw new Error(e);
+ TestMail mail = null;
+ while (null == mail) {
+ try {
+ mail = ter.recieve();
+ } catch (InterruptedException e) {
+ throw new Error(e);
+ }
}
+ return mail;
}
public static TestEmailReciever getMailReciever() {
subj.put("CN", "<empty>");
System.out.println("WARNING: DN was empty");
}
- String[] call = new String[] {
- "openssl", "ca",//
- "-in",
- "../../" + csrname,//
- "-cert",
- "../" + ca + ".crt",//
- "-keyfile",
- "../" + ca + ".key",//
- "-out",
- "../../" + crt.getPath(),//
- "-utf8",
- "-startdate",
- sdf.format(fromDate),//
- "-enddate",
- sdf.format(toDate),//
- "-batch",//
- "-md",
- rs.getString("md"),//
- "-extfile",
- "../" + f.getName(),//
-
- "-subj",
- Certificate.stringifyDN(subj),//
- "-config",
- "../selfsign.config"//
-
- };
+ String[] call;
+ synchronized (sdf) {
+ call = new String[] {
+ "openssl", "ca",//
+ "-in",
+ "../../" + csrname,//
+ "-cert",
+ "../" + ca + ".crt",//
+ "-keyfile",
+ "../" + ca + ".key",//
+ "-out",
+ "../../" + crt.getPath(),//
+ "-utf8",
+ "-startdate",
+ sdf.format(fromDate),//
+ "-enddate",
+ sdf.format(toDate),//
+ "-batch",//
+ "-md",
+ rs.getString("md"),//
+ "-extfile",
+ "../" + f.getName(),//
+
+ "-subj",
+ Certificate.stringifyDN(subj),//
+ "-config",
+ "../selfsign.config"//
+ };
+ }
+
if (ct == CSRType.SPKAC) {
call[2] = "-spkac";
}
+
Process p1 = Runtime.getRuntime().exec(call, null, new File("keys/unassured.ca"));
int waitFor = p1.waitFor();