@@ -927,14 +927,14 @@ public IRubyObject sysclose(final ThreadContext context) {
927
927
}
928
928
929
929
@ JRubyMethod
930
- public IRubyObject cert () {
931
- final Ruby runtime = getRuntime () ;
930
+ public IRubyObject cert (final ThreadContext context ) {
931
+ final Ruby runtime = context . runtime ;
932
932
if ( engine == null ) return runtime .getNil ();
933
933
934
934
try {
935
935
Certificate [] cert = engine .getSession ().getLocalCertificates ();
936
936
if ( cert != null && cert .length > 0 ) {
937
- return X509Cert .wrap (runtime , cert [0 ]);
937
+ return X509Cert .wrap (context , cert [0 ]);
938
938
}
939
939
}
940
940
catch (CertificateEncodingException e ) {
@@ -943,15 +943,20 @@ public IRubyObject cert() {
943
943
return runtime .getNil ();
944
944
}
945
945
946
+ // @Deprecated
947
+ public final IRubyObject cert () {
948
+ return cert (getRuntime ().getCurrentContext ());
949
+ }
950
+
946
951
@ 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 ;
949
954
if ( engine == null ) return runtime .getNil ();
950
955
951
956
try {
952
957
Certificate [] cert = engine .getSession ().getPeerCertificates ();
953
958
if ( cert .length > 0 ) {
954
- return X509Cert .wrap (runtime , cert [0 ]);
959
+ return X509Cert .wrap (context , cert [0 ]);
955
960
}
956
961
}
957
962
catch (CertificateEncodingException e ) {
@@ -965,18 +970,23 @@ public IRubyObject peer_cert() {
965
970
return runtime .getNil ();
966
971
}
967
972
973
+ // @Deprecated
974
+ public final IRubyObject peer_cert () {
975
+ return peer_cert (getRuntime ().getCurrentContext ());
976
+ }
977
+
968
978
@ 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 ;
971
981
if ( engine == null ) return runtime .getNil ();
972
982
973
983
try {
974
984
javax .security .cert .Certificate [] certs = engine .getSession ().getPeerCertificateChain ();
975
- RubyArray arr = runtime . newArray ( certs .length ) ;
985
+ IRubyObject [] cert_chain = new IRubyObject [ certs .length ] ;
976
986
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 ]);
978
988
}
979
- return arr ;
989
+ return runtime . newArrayNoCopy ( cert_chain ) ;
980
990
}
981
991
catch (javax .security .cert .CertificateEncodingException e ) {
982
992
throw X509Cert .newCertificateError (getRuntime (), e );
@@ -989,6 +999,11 @@ public IRubyObject peer_cert_chain() {
989
999
return runtime .getNil ();
990
1000
}
991
1001
1002
+ // @Deprecated
1003
+ public final IRubyObject peer_cert_chain () {
1004
+ return peer_cert_chain (getRuntime ().getCurrentContext ());
1005
+ }
1006
+
992
1007
@ JRubyMethod
993
1008
public IRubyObject cipher () {
994
1009
if ( engine == null ) return getRuntime ().getNil ();
0 commit comments