Skip to content

Commit 4b1ad4a

Browse files
authored
Merge pull request #223 from MariuszCwikla/issue_220
Fix Java::JavaLang::StringIndexOutOfBoundsException on ctx.cipher=[]
2 parents e50c04b + dae2539 commit 4b1ad4a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,10 @@ static Collection<Def> matchingCiphers(final String cipherString, final String[]
512512
}
513513

514514
int index = 0;
515-
switch ( part.charAt(0) ) {
516-
case '!': case '+': case '-': index++; break;
515+
if (part.length() > 0) {
516+
switch ( part.charAt(0) ) {
517+
case '!': case '+': case '-': index++; break;
518+
}
517519
}
518520

519521
final Collection<Def> matching;

src/test/ruby/ssl/test_context.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,12 @@ def test_context_ciphers
184184
assert_equal [], diff
185185
end unless java7? # would need to filter out stuff such as ECDHE-RSA-AES128-GCM-SHA256
186186

187+
def test_set_ciphers_empty_array
188+
context = OpenSSL::SSL::SSLContext.new
189+
ex = assert_raise(OpenSSL::SSL::SSLError) do
190+
context.ciphers = []
191+
end
192+
assert_equal "no cipher match", ex.message
193+
end
194+
187195
end

0 commit comments

Comments
 (0)