@@ -22,25 +22,32 @@ module SSL
2222
2323 def verify_certificate_identity ( cert , hostname )
2424 should_verify_common_name = true
25- cert . extensions . each { |ext |
25+ cert . extensions . each { |ext |
2626 next if ext . oid != "subjectAltName"
27- ext . value . split ( /,\s +/ ) . each { |general_name |
27+ ext . value . split ( /,\s +/ ) . each { |general_name |
28+ # MRI 1.9.3 (since we parse ASN.1 differently)
29+ # when 2 # dNSName in GeneralName (RFC5280)
2830 if /\A DNS:(.*)/ =~ general_name
2931 should_verify_common_name = false
3032 reg = Regexp . escape ( $1) . gsub ( /\\ \* / , "[^.]+" )
3133 return true if /\A #{ reg } \z /i =~ hostname
32- # NOTE: somehow we need the IP: canonical form
33- # seems there were failures elsewhere when not
34- # not sure how that's possible possible to-do!
34+ # MRI 1.9.3 (since we parse ASN.1 differently)
35+ # when 7 # iPAddress in GeneralName (RFC5280)
3536 elsif /\A IP(?: Address)?:(.*)/ =~ general_name
36- #elsif /\AIP Address:(.*)/ =~ general_name
3737 should_verify_common_name = false
3838 return true if $1 == hostname
39+ # NOTE: bellow logic makes little sense as we read exts differently
40+ #value = $1 # follows GENERAL_NAME_print() in x509v3/v3_alt.c
41+ #if value.size == 4
42+ # return true if value.unpack('C*').join('.') == hostname
43+ #elsif value.size == 16
44+ # return true if value.unpack('n*').map { |e| sprintf("%X", e) }.join(':') == hostname
45+ #end
3946 end
4047 }
4148 }
4249 if should_verify_common_name
43- cert . subject . to_a . each { |oid , value |
50+ cert . subject . to_a . each { |oid , value |
4451 if oid == "CN"
4552 reg = Regexp . escape ( value ) . gsub ( /\\ \* / , "[^.]+" )
4653 return true if /\A #{ reg } \z /i =~ hostname
0 commit comments