Skip to content

Commit 2826d1f

Browse files
committed
make sure empty object can be serialize via to_pem
this is mainly to match the specs/tests for the edge case that the CRL or PKCS10Request are empty object (created with new and without data) fixes #21 Sponsored by Lookout Inc.
1 parent 9ae920b commit 2826d1f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/org/jruby/ext/openssl/X509CRL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public IRubyObject initialize_copy(final IRubyObject obj) {
324324
public IRubyObject to_pem(final ThreadContext context) {
325325
StringWriter writer = new StringWriter();
326326
try {
327-
PEMInputOutput.writeX509CRL(writer, getCRL());
327+
PEMInputOutput.writeX509CRL(writer, crl);
328328
return RubyString.newString(context.runtime, writer.getBuffer());
329329
}
330330
catch (IOException e) {

src/main/java/org/jruby/ext/openssl/impl/PKCS10Request.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.io.IOException;
3333
import java.math.BigInteger;
3434
import java.util.ArrayList;
35-
3635
import java.security.KeyFactory;
3736
import java.security.PrivateKey;
3837
import java.security.PublicKey;
@@ -48,6 +47,7 @@
4847

4948
import org.bouncycastle.asn1.ASN1Sequence;
5049
import org.bouncycastle.asn1.ASN1Set;
50+
import org.bouncycastle.asn1.DLSequence;
5151
import org.bouncycastle.asn1.x500.X500Name;
5252
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
5353
import org.bouncycastle.pkcs.PKCS10CertificationRequestBuilder;
@@ -69,7 +69,6 @@
6969
import org.bouncycastle.operator.ContentVerifierProvider;
7070
import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder;
7171
import org.bouncycastle.pkcs.PKCSException;
72-
7372
import org.jruby.ext.openssl.SecurityHelper;
7473

7574
public class PKCS10Request {
@@ -169,7 +168,8 @@ private static SubjectPublicKeyInfo makePublicKeyInfo(PublicKey publicKey) {
169168

170169
public ASN1Sequence toASN1Structure() {
171170
if ( signedRequest == null ) {
172-
throw new IllegalStateException("request not signed");
171+
// return an empty Sequence
172+
return new DLSequence();
173173
}
174174
return ASN1Sequence.getInstance( signedRequest.toASN1Structure() );
175175
}

0 commit comments

Comments
 (0)