@@ -927,14 +927,14 @@ public IRubyObject sysclose(final ThreadContext context) {
927927 }
928928
929929 @ JRubyMethod
930- public IRubyObject cert () {
931- final Ruby runtime = getRuntime () ;
930+ public IRubyObject cert (final ThreadContext context ) {
931+ final Ruby runtime = context . runtime ;
932932 if ( engine == null ) return runtime .getNil ();
933933
934934 try {
935935 Certificate [] cert = engine .getSession ().getLocalCertificates ();
936936 if ( cert != null && cert .length > 0 ) {
937- return X509Cert .wrap (runtime , cert [0 ]);
937+ return X509Cert .wrap (context , cert [0 ]);
938938 }
939939 }
940940 catch (CertificateEncodingException e ) {
@@ -943,15 +943,20 @@ public IRubyObject cert() {
943943 return runtime .getNil ();
944944 }
945945
946+ // @Deprecated
947+ public final IRubyObject cert () {
948+ return cert (getRuntime ().getCurrentContext ());
949+ }
950+
946951 @ JRubyMethod
947- public IRubyObject peer_cert () {
948- final Ruby runtime = getRuntime () ;
952+ public IRubyObject peer_cert (final ThreadContext context ) {
953+ final Ruby runtime = context . runtime ;
949954 if ( engine == null ) return runtime .getNil ();
950955
951956 try {
952957 Certificate [] cert = engine .getSession ().getPeerCertificates ();
953958 if ( cert .length > 0 ) {
954- return X509Cert .wrap (runtime , cert [0 ]);
959+ return X509Cert .wrap (context , cert [0 ]);
955960 }
956961 }
957962 catch (CertificateEncodingException e ) {
@@ -965,18 +970,23 @@ public IRubyObject peer_cert() {
965970 return runtime .getNil ();
966971 }
967972
973+ // @Deprecated
974+ public final IRubyObject peer_cert () {
975+ return peer_cert (getRuntime ().getCurrentContext ());
976+ }
977+
968978 @ JRubyMethod
969- public IRubyObject peer_cert_chain () {
970- final Ruby runtime = getRuntime () ;
979+ public IRubyObject peer_cert_chain (final ThreadContext context ) {
980+ final Ruby runtime = context . runtime ;
971981 if ( engine == null ) return runtime .getNil ();
972982
973983 try {
974984 javax .security .cert .Certificate [] certs = engine .getSession ().getPeerCertificateChain ();
975- RubyArray arr = runtime . newArray ( certs .length ) ;
985+ IRubyObject [] cert_chain = new IRubyObject [ certs .length ] ;
976986 for ( int i = 0 ; i < certs .length ; i ++ ) {
977- arr . append ( X509Cert .wrap (runtime , certs [i ]) );
987+ cert_chain [ i ] = X509Cert .wrap (context , certs [i ]);
978988 }
979- return arr ;
989+ return runtime . newArrayNoCopy ( cert_chain ) ;
980990 }
981991 catch (javax .security .cert .CertificateEncodingException e ) {
982992 throw X509Cert .newCertificateError (getRuntime (), e );
@@ -989,6 +999,11 @@ public IRubyObject peer_cert_chain() {
989999 return runtime .getNil ();
9901000 }
9911001
1002+ // @Deprecated
1003+ public final IRubyObject peer_cert_chain () {
1004+ return peer_cert_chain (getRuntime ().getCurrentContext ());
1005+ }
1006+
9921007 @ JRubyMethod
9931008 public IRubyObject cipher () {
9941009 if ( engine == null ) return getRuntime ().getNil ();
0 commit comments