|
40 | 40 | import java.security.PrivateKey; |
41 | 41 |
|
42 | 42 | import org.bouncycastle.asn1.ASN1Encoding; |
| 43 | +import org.bouncycastle.asn1.ASN1Sequence; |
43 | 44 | import org.bouncycastle.asn1.ASN1Set; |
44 | 45 | import org.bouncycastle.asn1.ASN1ObjectIdentifier; |
45 | 46 | import org.bouncycastle.asn1.pkcs.Attribute; |
@@ -151,13 +152,31 @@ private static IRubyObject newName(final ThreadContext context, X500Name name) { |
151 | 152 | @Override |
152 | 153 | @JRubyMethod(visibility = Visibility.PRIVATE) |
153 | 154 | public IRubyObject initialize_copy(IRubyObject obj) { |
154 | | - final Ruby runtime = getRuntime(); |
155 | | - warn(runtime.getCurrentContext(), "WARNING: unimplemented method called: OpenSSL::X509::Request#initialize_copy"); |
156 | | - |
157 | 155 | if ( this == obj ) return this; |
158 | 156 |
|
159 | 157 | checkFrozen(); |
160 | | - // subject = public_key = null; |
| 158 | + |
| 159 | + final X509Request that = (X509Request) obj; |
| 160 | + final ThreadContext context = getRuntime().getCurrentContext(); |
| 161 | + |
| 162 | + this.subject = that.subject == null ? null : newName(context, getX500Name(that.subject)); |
| 163 | + this.public_key = that.public_key == null ? null : (PKey) that.public_key.dup(); |
| 164 | + this.version = that.version; |
| 165 | + |
| 166 | + this.attributes.clear(); |
| 167 | + for ( X509Attribute attribute : that.attributes ) { |
| 168 | + this.attributes.add( (X509Attribute) attribute.dup() ); |
| 169 | + } |
| 170 | + |
| 171 | + final PKCS10Request request = that.request; |
| 172 | + if ( request != null ) { |
| 173 | + final ASN1Sequence requestSequence = request.toASN1Structure(); |
| 174 | + this.request = requestSequence.size() == 0 ? null : new PKCS10Request(requestSequence); |
| 175 | + } |
| 176 | + else { |
| 177 | + this.request = null; |
| 178 | + } |
| 179 | + |
161 | 180 | return this; |
162 | 181 | } |
163 | 182 |
|
|
0 commit comments