diff --git a/src/main/java/org/jruby/ext/openssl/X509Extension.java b/src/main/java/org/jruby/ext/openssl/X509Extension.java index 3c9c3fa2..5f8bf8c8 100644 --- a/src/main/java/org/jruby/ext/openssl/X509Extension.java +++ b/src/main/java/org/jruby/ext/openssl/X509Extension.java @@ -661,11 +661,16 @@ private static boolean formatGeneralName(final GeneralName name, final ByteList append(':'); final byte[] ip = ((ASN1OctetString) name.getName()).getOctets(); int len = ip.length; boolean ip4 = len == 4; - for ( int i = 0; i < ip.length; i++ ) { - out.append( ConvertBytes.intToCharBytes( ((int) ip[i]) & 0xff ) ); - if ( i != len - 1 ) { - if ( ip4 ) out.append('.'); - else out.append(':').append(':'); + if ( ip4 ) { + for ( int i = 0; i < ip.length; i++ ) { + out.append( ConvertBytes.intToCharBytes( ((int) ip[i]) & 0xff ) ); + if ( i != len - 1 ) out.append('.'); + } + } + else { + for ( int i = 0; i < ip.length; i += 2 ) { + out.append( ConvertBytes.intToHexBytes( ((ip[i] & 0xff) << 8 | (ip[i+1] & 0xff)) ) ); + if ( i != len - 2 ) out.append(':'); } } break;