-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic tests for PKCS#10 #556
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.mozilla.jss.tests; | ||
|
||
import java.security.PublicKey; | ||
import java.security.KeyPair; | ||
import java.security.interfaces.*; | ||
|
||
import org.mozilla.jss.*; | ||
import org.mozilla.jss.crypto.*; | ||
import org.mozilla.jss.netscape.security.pkcs.*; | ||
import org.mozilla.jss.netscape.security.x509.*; | ||
|
||
public class PKCS10Test { | ||
public static void main(String[] args) throws Exception { | ||
CryptoManager cm = CryptoManager.getInstance(); | ||
|
||
CertAndKeyGen ckg = new CertAndKeyGen("RSA", "SHA256withRSA"); | ||
ckg.generate(4096); | ||
PKCS10 csr = ckg.getCertRequest(new X500Name("CN=localhost")); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.mozilla.jss.tests; | ||
|
||
import java.io.*; | ||
import java.security.KeyPair; | ||
|
||
import org.mozilla.jss.*; | ||
import org.mozilla.jss.asn1.*; | ||
import org.mozilla.jss.crypto.*; | ||
import org.mozilla.jss.pkcs10.*; | ||
import org.mozilla.jss.pkix.primitive.*; | ||
|
||
public class TestCertificationRequest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we run this test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it requires a CSR to run so I ran it manually. We didn't previously run this test either, but it at least moves it into the correct place in case we want to run it automatically in the future. I think this test should/could be expanded with actual uses of these classes from Dogtag PKI, but we should leave it for a future sprint and/or QE to do. |
||
public static void main(String[] argv) throws Exception { | ||
if (argv.length > 2 || argv.length < 1) { | ||
System.out.println("Usage: TestCertificationRequest <dbdir> [<certfile>]"); | ||
System.exit(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should generate a non-zero return code since it fails the test. |
||
} | ||
|
||
CryptoManager cm = CryptoManager.getInstance(); | ||
|
||
CertificationRequest cert; | ||
|
||
// read in a cert | ||
FileInputStream fis = new FileInputStream(argv[1]); | ||
try (BufferedInputStream bis = new BufferedInputStream(fis)) { | ||
cert = (CertificationRequest) CertificationRequest.getTemplate().decode(bis); | ||
} | ||
|
||
CertificationRequestInfo info = cert.getInfo(); | ||
|
||
info.print(System.out); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add some validations for the CSR?