@@ -518,26 +518,26 @@ public IRubyObject setup(final ThreadContext context) {
518
518
519
519
@ JRubyMethod
520
520
public RubyArray ciphers (final ThreadContext context ) { // SSL_CTX_get_ciphers
521
- return matchedCiphersWithCache (context );
521
+ return matchedCiphersWithCache (context , this . ciphers );
522
522
}
523
523
524
- private RubyArray matchedCiphersWithCache (final ThreadContext context ) {
524
+ private RubyArray matchedCiphersWithCache (final ThreadContext context , final String ciphers ) {
525
525
final CipherListCache cache = cipherListCache ;
526
526
if ( protocol .equals (cache .protocol ) && ciphers .equals (cache .ciphers ) ) {
527
527
return newSharedArray (cache .cipherList );
528
528
}
529
529
530
- final RubyArray match = matchedCiphers (context );
530
+ final RubyArray match = matchedCiphers (context , ciphers );
531
531
cipherListCache = new CipherListCache (protocol , ciphers , match );
532
532
return newSharedArray (match );
533
533
}
534
534
535
- private RubyArray matchedCiphers (final ThreadContext context ) {
535
+ private RubyArray matchedCiphers (final ThreadContext context , final String ciphers ) {
536
536
final Ruby runtime = context .runtime ;
537
537
try {
538
538
final String [] supported = getSupportedCipherSuites (context , protocol );
539
539
final Collection <CipherStrings .Def > cipherDefs =
540
- CipherStrings .matchingCiphers (this . ciphers , supported , false );
540
+ CipherStrings .matchingCiphers (ciphers , supported , false );
541
541
542
542
final IRubyObject [] cipherList = new IRubyObject [ cipherDefs .size () ];
543
543
@@ -562,8 +562,9 @@ private static RubyArray newSharedArray(RubyArray array) {
562
562
563
563
@ JRubyMethod (name = "ciphers=" )
564
564
public IRubyObject set_ciphers (final ThreadContext context , final IRubyObject ciphers ) {
565
+ String cipherString ;
565
566
if ( ciphers .isNil () ) {
566
- this . ciphers = CipherStrings .SSL_DEFAULT_CIPHER_LIST ;
567
+ cipherString = CipherStrings .SSL_DEFAULT_CIPHER_LIST ;
567
568
}
568
569
else if ( ciphers instanceof RubyArray ) {
569
570
final RubyArray ciphs = (RubyArray ) ciphers ;
@@ -581,20 +582,23 @@ else if ( ciphers instanceof RubyArray ) {
581
582
cipherStr .append (sep ).append ( elem .toString () );
582
583
sep = ":" ;
583
584
}
584
- this . ciphers = cipherStr .toString ();
585
+ cipherString = cipherStr .toString ();
585
586
}
586
587
else {
587
- this . ciphers = ciphers .asString ().toString ();
588
+ cipherString = ciphers .asString ().toString ();
588
589
}
589
590
590
- if (this . ciphers .equals (CipherStrings .SSL_DEFAULT_CIPHER_LIST )) {
591
- this . ciphers = CipherStrings .SSL_DEFAULT_CIPHER_LIST ; // due caching
591
+ if (cipherString .equals (CipherStrings .SSL_DEFAULT_CIPHER_LIST )) {
592
+ cipherString = CipherStrings .SSL_DEFAULT_CIPHER_LIST ; // due caching
592
593
}
593
594
594
- if ( matchedCiphersWithCache (context ).isEmpty () ) {
595
+ System .out .println ("cipherString: " + cipherString + " " + matchedCiphersWithCache (context , cipherString ).isEmpty ());
596
+
597
+ if ( matchedCiphersWithCache (context , cipherString ).isEmpty () ) {
595
598
throw newSSLError (context .runtime , "no cipher match" );
596
599
}
597
600
601
+ this .ciphers = cipherString ;
598
602
return ciphers ;
599
603
}
600
604
0 commit comments