pax_global_header 0000666 0000000 0000000 00000000064 12567644621 0014527 g ustar 00root root 0000000 0000000 52 comment=3b4bc77f678f91070bf7dca6db12c4bc4b4d09c1
jruby-openssl-0.9.11/ 0000775 0000000 0000000 00000000000 12567644621 0014433 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/.classpath 0000664 0000000 0000000 00000001735 12567644621 0016424 0 ustar 00root root 0000000 0000000
jruby-openssl-0.9.11/.gitignore 0000664 0000000 0000000 00000000076 12567644621 0016426 0 ustar 00root root 0000000 0000000 *.gemspec.xml
pkg
*.jar
target
build.log
.idea
*.lock
lib/org
jruby-openssl-0.9.11/.settings/ 0000775 0000000 0000000 00000000000 12567644621 0016351 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/.settings/org.eclipse.core.resources.prefs 0000664 0000000 0000000 00000000125 12567644621 0024562 0 ustar 00root root 0000000 0000000 eclipse.preferences.version=1
encoding//src/main/java=utf-8
encoding/=utf-8
jruby-openssl-0.9.11/.settings/org.eclipse.jdt.core.prefs 0000664 0000000 0000000 00000000356 12567644621 0023337 0 ustar 00root root 0000000 0000000 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6
jruby-openssl-0.9.11/.settings/org.eclipse.m2e.core.prefs 0000664 0000000 0000000 00000000126 12567644621 0023234 0 ustar 00root root 0000000 0000000 activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
jruby-openssl-0.9.11/.travis.yml 0000664 0000000 0000000 00000001732 12567644621 0016547 0 ustar 00root root 0000000 0000000 language: ruby
sudo: false
rvm:
- jruby
jdk:
- openjdk6
- oraclejdk7
- oraclejdk8
env:
- TEST_PROFILE=test-1.6.8
- TEST_PROFILE=test-1.7.4
- TEST_PROFILE=test-1.7.13
- TEST_PROFILE=test-1.7.18
- TEST_PROFILE=test-1.7.21
- TEST_PROFILE=test-9000
install: echo 'no bundle install atm!'
# script: mvn verify -P $TEST_PROFILE
script: if [[ -v TEST_COMMAND ]]; then $TEST_COMMAND; else mvn verify -P $TEST_PROFILE; fi
matrix:
exclude:
- jdk: openjdk6
env: TEST_PROFILE=test-9000
include:
- jdk: oraclejdk7
env: TEST_COMMAND="jruby -S rake integration:install integration:test"
rvm: jruby
- jdk: oraclejdk8
env: TEST_COMMAND="jruby -S rake integration:install integration:test"
rvm: jruby
notifications:
irc:
channels:
- "irc.freenode.org#jruby"
on_success: change
on_failure: always
template:
- "%{repository} (%{branch}:%{commit} by %{author}): %{message} (%{build_url})"
skip_join: true
jruby-openssl-0.9.11/Gemfile 0000664 0000000 0000000 00000000130 12567644621 0015720 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org'
# Specify your gem's dependencies in the gemspec
gemspec
jruby-openssl-0.9.11/History.md 0000664 0000000 0000000 00000042021 12567644621 0016415 0 ustar 00root root 0000000 0000000 ## 0.9.11
* add TLSv1_1_client, TLSv1_1_server, TLSv1_2_client and TLSv1_2_server options
to ssl_version (#65)
* **regression** make sure we hold a buffered reader so that the loop continues
reading PEMs - previously introduced an incompatibility with cert verify (#67)
* support negotiating up to TLS1_1 and TLS1_2 when the server supports these
ssl_versions (#63)
## 0.9.10
* **regression** reverted fix for #49 (as it needs more work/testing) :
keep the default x509 certs and directories in line with MRI (#49), only if
they do not exists fallback on cacerts from the java.home/lib/security/cacerts
## 0.9.9
* **regression** causing to re-package a RaiseException in `SSLSocket#accept`
* fix load error: jopenssl/load -- java.lang.VerifyError: using BC 1.51 or 1.52 (#62)
* keep the default x509 certs and directories in line with MRI (#49), only if
they do not exists fallback on cacerts from the java.home/lib/security/cacerts
## 0.9.8
* refactor `PKCS5.pbkdf2_hmac_sha1` to use BC APIs
thus less dependent on provider internals (jruby/jruby#3025)
* HMAC - use our SimpleKey impl so that there's less[] copy
... also allows for an empty key to work like MRI (jruby/jruby#2854)
* fixing oaep encryption to use correct algorithm (#54)
* [experimental] support NOT loading any (BC) jars on our own ... (#10)
* disable DHE (by default) on Java <= 7 ... on Java 8 we (still) force 1024/2048
(see jruby/jruby#2872 and #45)
* **regression** handle parsing of "incomplete" X.509 certs like MRI does (#42)
* implement a CRL/certificate caching (for now off by default) in Lookup
... set *-J-Djruby.openssl.x509.lookup.cache=true* to enable
* improve Store helper concurrency (with less synchronization)
* reviewed OpenSSL's .rb parts to match those present in MRI 1.9.3 / 2.2.2
* initial support for `OpenSSL::SSL::Session` (id, time, timeout work)
* session_cache_mode as present in OpenSSL makes no sense with Java APIs
* use the set SSLContext#session_cache_size on the underlying javax.net API
* tidy up SSLSocket's internals + add stack-trace debugging on accept/connect
* add SSLSocket ssl_version property like MRI has (#38)
* avoid unnecessary `_initialize` naming - it's confusing to see in JVM tools
* use SecurityHelper to get a X.509 certificate factory
we'll know prefer BC's X.509 factory over the built-in (Sun provider) one
## 0.9.7
* put in some more ossl to jsse mappings for SSL/TLS
(SSL_DHE_xxx, TLS_ECDH_xxx, TLS_ECDHE_xxx)
* exclude SSLv2 in reported METHODS (all fine to close jruby/jruby#1874)
* support passing ssl_version as an argument to initialize SSLContext.new ...
* now that we've matched w MRI's SSLContext::METHODS don't report custom ones
* more ssl_version= compatibility fixes that match MRI (jruby/jruby#1736)
* support setting ssl_version = "TLSv1_1" (or "TLSv1_2") just like MRI
* **regression** make sure version is set when reading encoded certificate
+ signature algorithm should be read as well when decoding certificate (#39)
* better accept handshake errors instead of "General SSLEngine problem (#37)
* trying to decode DER application specific objects (based on patch from #36)
* we've not been compatible with MRI's DES (EDE) - partly due DES(3) ECB
fixing jruby/jruby#2617 as well as jruby/jruby#931
* exclude reporting algorithms with CFB-1 cipher mode as supported (due #35)
* do not change CFB1 to CFB ... it's something different (although broken on BC)
* attempt to deal with update/final buffering incompatibility with MRI
* fix HMAC digest incorrect when data contains invalid characters (#33)
* add Gemfile and specify ruby-maven as dependency
* use SafePropertyAccessor to access properties instead of directly (#28)
* make sure SSLSocket's cipher and hostname are nil by default (avoids NPE)
* update to (packed) BC version 1.50 + start declaring 1.51 as semi-supported
## 0.9.6
* ClassCastException still happen deep within BC - turn them into SignatureExeption
* make sure empty object can be serialize via to_pem
* use the classname as message in case the exception has no message (jruby/jruby#2249)
* make sure X509Object list is synchronized properly
* use JRubyFile to get input-stream to file-resource fixes #11
* Cache the discovered classes for digest engines. Fixes #15.
* avoid the rest of Ruby.getGlobalRuntime usages - only worked in 1 runtime envs
* refactored CRL - using light-weight BC API (avoids deprecated X.509 generator)
* implement X509::Certificate#to_text for happiness (the MRI-way - only RSA for now)
* allow to "fake" our inspect() support and match MRI's X509::Certificate#inspect
* decode BC's ASN1Enumarated into a OpenSSL::ASN1::Enumerated
* we can (ASN.1) encode an infinite-length bit-string constructive
* turns out all ASN1 primitives in MRI have the infinite_length attribute
* support (so-far only dummy) @servername_cb attribute on SSLSocket
* handle (CRL) extension's issuerAltName wrapping without an exception
* fix SSL (cert) verification - now working on 1.8/1.9 better than before
* do not skip first 2 bytes of key identifier hash when encoding to hex!
* match X.509 extension short-comings of the Java API in order to align with MRI
* improve cert.extension's value - *extendedKeyUsage* was not returned correctly
* make sure ASN1::ObjectId.new(...).ln and ASN1::ObjectId.new(...).sn are correct!
* better working to_der conversion esp. with constructives (indefinite lengths)
* improve our ASN1 decoding for better MRI compatibility
* avoiding Krypt gem dependency completely (was used for OpenSSL::PKCS5)
* cleanup OpenSSL::Digest internals - make sure block_length works for more
* OpenSSL deprecated_warning_flag and check_func API compatibility stubs
* do not force loading of jar-dependencies + possibly respect jars skipped
* X509::Name.to_a compatibility - MRI seems to never return "UNDEF"
experimental support for passing down "real" Java JCE cipher names
* rewriten Cipher internals - now faster, slimmer and more compatible than ever!
* rebuilt our global ASN1Registry and refactored it (back) internally to use string oids
* report OpenSSL::VERSION **1.1.0** since 1.9.3
* fill RaiseException's cause whenever we use a factory passing down a Throwable
* allow X509::Revoked.serial= to receive an integer
* make sure X509::CRL's to_text representation si (fully) MRI compatible
* handle authority key-id unwrapping correctly in X509::Extension#value
* long time coming - OpenSSL::X509::CRL support for loading revoked entries (#5)
* Reflect Java cacert location in DEFAULT_CERT_* constants (jruby/jruby#1953)
* X509::Certificate.new MRI compatibility + make sure inspect works the same
* BN.inspect() and make sure BN.new(0) works just fine (both as in MRI)
* X509::CRL instantiation compatibility with MRI
* inspect() X509::Certificate an X509::CRL just like MRI does
* handle OpenSSL::X509::Store.add error messages correctly (fix based on #6)
* update to using BC 1.49 by default (still compatible with older versions)
* implement X509::StoreContext#current_crl method
* support X509::StoreContext cleanup and error_depth instance methods
* support disabling of warnings using system property -Djruby.openssl.warn
* Throw error when chain certs are *not* OpenSSL::X509::Certificate (#3)
* avoid using JRuby IO APIs (will likely not work in 9k)
* make 'jopenssl/load' also work on jruby-1.6.8 mode 1.9
## 0.9.5
MASSIVE internal "rewrite" to avoid depending on a registered (BC) security
provider. This releases restores compatibility with BC version 1.47 while being
compatible with newer bouncy-castle jars as well (1.48, 1.49 and 1.50).
* handle SSLErrorWaitReadable/Writable as SSLErrors on Ruby 1.8 and 1.9 mode
* Treat SSL NOT_HANDSHAKING as FINISHED
* only add DER.TRUE when encoding X.509 extension when non-critical
* do not der encode non-critical flag in X509::Extension (jruby/jruby#389)
* SSLContext internals + support `SSLContext::METHODS` correctly (jruby/jruby#1596)
* correct visibility of initialize* and respond_to_missing? methods
* fix spinning indefinitely on partial TLS record (jruby/jruby#1280)
* Support file input for PKey::RSA.new
* fix bug https://github.com/jruby/jruby/issues/1156
* openssl: add handling for base 0 to new and to_s
## 0.9.4
* Fix compatibility wiht Bouncy Castle 1.49.
## 0.9.3
* Allow options passed to nonblock methods (not impl'ed yet)
* Make ClassIndex into an enum, to prevent issues like jruby/jruby#1004
== ...
## 0.7.7
This release includes bug fixes.
* JRUBY-6622: Support loading encrypted RSA key with PBES2
* JRUBY-4326: Confusing (and late) OpenSSL error message
* JRUBY-6579: Avoid ClassCastException for public key loading
* JRUBY-6515: sending UTF-8 data over SSL can hang with openssl
* Update tests to sync with CRuby ruby_1_9_3
## 0.7.6
This release includes initial implementation of PKCS12 by Owen Ou.
* JRUBY-5066: Implement OpenSSL::PKCS12 (only for simple case)
* JRUBY-6385: Assertion failure with -J-ea
## 0.7.5
This release improved 1.9 mode support with help of
Duncan Mak . Now jruby-ossl gem includes both 1.8 and 1.9
libraries and part of features should work fine on 1.9 mode, too.
* JRUBY-6270: Wrong keyUsage check for SSL server
* JRUBY-6260: OpenSSL::ASN1::Integer#value incompatibility
* JRUBY-6044: Improve Ecrypted RSA/DSA pem support
* JRUBY-5972: Allow to load/dump empty PKCS7 data
* JRUBY-5834: Fix X509Name handling; X509Name RDN can include multiple elements
* JRUBY-5362: Improved 1.9 support
* JRUBY-4992: Warn if loaded by non JRuby interpreter
## 0.7.4
* JRUBY-5519: Avoid String encoding dependency in DER loading. PEM loading
failed on JRuby 1.6.x. Fixed.
* JRUBY-5510: Add debug information to released jar
* JRUBY-5478: Update bouncycastle jars to the latest version. (1.46)
## 0.7.3
* JRUBY-5200: Net::IMAP + SSL(imaps) login could hang. Fixed.
* JRUBY-5253: Allow to load the certificate file which includes private
key for activemarchant compatibility.
* JRUBY-5267: Added SSL socket error-checks to avoid busy loop under an
unknown condition.
* JRUBY-5316: Improvements for J9's IBMJCE support. Now all testcases
pass on J9 JDK 6.
## 0.7.2
* JRUBY-5126: Ignore Cipher#reset and Cipher#iv= when it's a stream
cipher (Net::SSH compatibility)
* JRUBY-5125: let Cipher#name for 'rc4' to be 'RC4' (Net::SSH
compatibility)
* JRUBY-5096: Fixed inconsistent Certificate verification behavior
* JRUBY-5060: Avoid NPE from to_pem for empty X509 Objects
* JRUBY-5059: SSLSocket ignores Timeout (Fixed)
* JRUBY-4965: implemented OpenSSL::Config
* JRUBY-5023: make Certificate#signature_algorithm return correct algo
name; "sha1WithRSAEncryption" instead of "SHA1"
* JRUBY-5024: let HMAC.new accept a String as a digest name
* JRUBY-5018: SSLSocket holds selectors, keys, preventing quick
cleanup of resources when dereferenced
## 0.7.1
NOTE: Now BouncyCastle jars has moved out to its own gem "bouncy-castle-java"
http://rubygems.org/gems/bouncy-castle-java. You don't need to care about it
because "jruby-openssl" gem depends on it from now on.
* JRUBY-4826 net/https client possibly raises "rbuf_fill': End of file
reached (EOFError)" for HTTP chunked read.
* JRUBY-4900: Set proper String to OpenSSL::OPENSSL_VERSION. Make sure
it's not an OpenSSL artifact: "OpenSSL 0.9.8b 04 May 2006
(JRuby-OpenSSL fake)" -> "jruby-ossl 0.7.1"
* JRUBY-4975: Moving BouncyCastle jars out to its own gem.
## 0.7
* Follow MRI 1.8.7 openssl API changes
* Fixes so that jruby-openssl can run on appengine
* Many bug and compatibility fixes, see below.
* This is the last release that will be compatible with JRuby 1.4.x.
* Compatibility issues
- JRUBY-4342: Follow ruby-openssl of CRuby 1.8.7.
- JRUBY-4346: Sync tests with tests for ruby-openssl of CRuby 1.8.7.
- JRUBY-4444: OpenSSL crash running RubyGems tests
- JRUBY-4075: Net::SSH gives OpenSSL::Cipher::CipherError "No message
available"
- JRUBY-4076: Net::SSH padding error using 3des-cbc on Solaris
- JRUBY-4541: jruby-openssl doesn't load on App Engine.
- JRUBY-4077: Net::SSH "all authorization methods failed" Solaris -> Solaris
- JRUBY-4535: Issues with the BouncyCastle provider
- JRUBY-4510: JRuby-OpenSSL crashes when JCE fails a initialise bcprov
- JRUBY-4343: Update BouncyCastle jar to upstream version; jdk14-139 ->
jdk15-144
Cipher issues
- JRUBY-4012: Initialization vector length handled differently than in MRI
(longer IV sequence are trimmed to fit the required)
- JRUBY-4473: Implemented DSA key generation
- JRUBY-4472: Cipher does not support RC4 and CAST
- JRUBY-4577: InvalidParameterException 'Wrong keysize: must be equal to 112 or
168' for DES3 + SunJCE
SSL and X.509(PKIX) issues
- JRUBY-4384: TCP socket connection causes busy loop of SSL server
- JRUBY-4370: Implement SSLContext#ciphers
- JRUBY-4688: SSLContext#ciphers does not accept 'DEFAULT'
- JRUBY-4357: SSLContext#{setup,ssl_version=} are not implemented
- JRUBY-4397: SSLContext#extra_chain_cert and SSLContext#client_ca
- JRUBY-4684: SSLContext#verify_depth is ignored
- JRUBY-4398: SSLContext#options does not affect to SSL sessions
- JRUBY-4360: Implement SSLSocket#verify_result and dependents
- JRUBY-3829: SSLSocket#read should clear given buffer before concatenating
(ByteBuffer.java:328:in `allocate': java.lang.IllegalArgumentException when
returning SOAP queries over a certain size)
- JRUBY-4686: SSLSocket can drop last chunk of data just before inbound channel
close
- JRUBY-4369: X509Store#verify_callback is not called
- JRUBY-4409: OpenSSL::X509::Store#add_file corrupts when it includes
certificates which have the same subject (problem with
ruby-openid-apps-discovery (github jruby-openssl issue #2))
- JRUBY-4333: PKCS#8 formatted privkey read
- JRUBY-4454: Loading Key file as a Certificate causes NPE
- JRUBY-4455: calling X509::Certificate#sign for the Certificate initialized
from PEM causes IllegalStateException
PKCS#7 issues
- JRUBY-4379: PKCS7#sign failed for DES3 cipher algorithm
- JRUBY-4428: Allow to use DES-EDE3-CBC in PKCS#7 w/o the Policy Files (rake
test doesn't finish on JDK5 w/o policy files update)
Misc
- JRUBY-4574: jruby-openssl deprecation warning cleanup
- JRUBY-4591: jruby-1.4 support
## 0.6
* This is a recommended upgrade to jruby-openssl. A security problem
involving peer certificate verification was found where failed
verification silently did nothing, making affected applications
vulnerable to attackers. Attackers could lead a client application
to believe that a secure connection to a rogue SSL server is
legitimate. Attackers could also penetrate client-validated SSL
server applications with a dummy certificate. Your application would
be vulnerable if you're using the 'net/https' library with
OpenSSL::SSL::VERIFY_PEER mode and any version of jruby-openssl
prior to 0.6. Thanks to NaHi (NAKAMURA Hiroshi) for finding the
problem and providing the fix. See
http://www.jruby.org/2009/12/07/vulnerability-in-jruby-openssl.html
for details.
* This release addresses CVE-2009-4123 which was reserved for the
above vulnerability.
* Many fixes from NaHi, including issues related to certificate
verification and certificate store purpose verification.
- implement OpenSSL::X509::Store#set_default_paths
- MRI compat. fix: OpenSSL::X509::Store#add_file
- Fix nsCertType handling.
- Fix Cipher#key_len for DES-EDE3: 16 should be 24.
- Modified test expectations around Cipher#final.
* Public keys are lazily instantiated when the
X509::Certificate#public_key method is called (Dave Garcia)
## 0.5.2
Multiple bugs fixed:
* JRUBY-3895 Could not verify server signature with net-ssh against Cygwin
* JRUBY-3864 jruby-openssl depends on Base64Coder from JvYAMLb
* JRUBY-3790 JRuby-OpenSSL test_post_connection_check is not passing
* JRUBY-3767 OpenSSL ssl implementation doesn't support client auth
* JRUBY-3673 jRuby-OpenSSL does not properly load certificate authority file
## 0.5.1
* Multiple fixes by Brice Figureau to get net/ssh working. Requires JRuby 1.3.1
to be 100%
* Fix by Frederic Jean for a character-decoding issue for some certificates
## 0.5
* Fixed JRUBY-3614: Unsupported HMAC algorithm (HMACSHA-256)
* Fixed JRUBY-3570: ActiveMerchant's AuthorizeNet Gateway throws OpenSSL Cert
Validation Error, when there should be no error
* Fixed JRUBY-3557 Class cast exception in PKeyRSA.java
* Fixed JRUBY-3468 X.509 certificates: subjectKeyIdentifier corrupted
* Fixed JRUBY-3285 Unsupported HMAC algorithm (HMACSHA1) error when generating
digest
* Misc code cleanup
## 0.2
* Enable remaining tests; fix a nil string issue in SSLSocket.sysread
(JRUBY-1888)
* Fix socket buffering issue by setting socket IO sync = true
* Fix bad file descriptor issue caused by unnecessary close (JRUBY-2152)
* Fix AES key length (JRUBY-2187)
* Fix cipher initialization (JRUBY-1100)
* Now, only compatible with JRuby 1.1
## 0.1.1
* Fixed blocker issue preventing HTTPS/SSL from working (JRUBY-1222)
## 0.1
* PLEASE NOTE: This release is not compatible with JRuby releases earlier than
1.0.3 or 1.1b2. If you must use JRuby 1.0.2 or earlier, please install the
0.6 release.
* Release coincides with JRuby 1.0.3 and JRuby 1.1b2 releases
* Simultaneous support for JRuby trunk and 1.0 branch
* Start of support for OpenSSL::BN
## 0.0.5 and prior
* Initial versions with maintenance updates
jruby-openssl-0.9.11/LICENSE.txt 0000664 0000000 0000000 00000003766 12567644621 0016272 0 ustar 00root root 0000000 0000000 JRuby-OpenSSL is distributed under the same license as JRuby a tri EPL/GPL/LGPL
license. You can use it, redistribute it and/or modify it under the terms of the:
Eclipse Public License version 1.0
GNU General Public License version 2.0
GNU Lesser General Public License version 2.1
The contents of this file are subject to the Common Public License Version 1.0
(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.eclipse.org/legal/cpl-v10.html
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR APARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Copyright (C) 2007-2009 Ola Bini
Copyright (C) 2009-2015 The JRuby Team
Alternatively, the contents of this file may be used under the terms of
either of the GNU General Public License Version 2 or later (the "GPL"),
or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the EPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the EPL, the GPL or the LGPL.
JRuby-OpenSSL includes software by The Legion of the Bouncy Castle Inc.
Please, visit (http://bouncycastle.org/license.html) for licensing details.
jruby-openssl-0.9.11/Mavenfile 0000664 0000000 0000000 00000016356 12567644621 0016277 0 ustar 00root root 0000000 0000000 #-*- mode: ruby -*-
gemspec :jar => 'jopenssl', :include_jars => true
sonatype_url = 'https://oss.sonatype.org/content/repositories/snapshots/'
snapshot_repository :id => 'sonatype', :url => sonatype_url
distribution_management do
snapshot_repository :id => :ossrh, :url => 'https://oss.sonatype.org/content/repositories/snapshots'
repository :id => :ossrh, :url => 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
end
java_target = '1.6'
gen_sources = '${basedir}/target/generated-sources' # hard-coded in AnnotationBinder
plugin( 'org.codehaus.mojo:exec-maven-plugin', '1.3.2' ) do
=begin
invoker_main = '-Djruby.bytecode.version=${compiler.target}'
#invoker_main << ' -classpath '
invoker_main << ' org.jruby.anno.InvokerGenerator'
invoker_main << " #{gen_sources}/annotated_classes.txt ${project.build.outputDirectory}"
dependency 'org.jruby', 'jruby-core', '${jruby.version}'
execute_goal :java, :id => 'invoker-generator', :phase => 'process-classes',
:mainClass => 'org.jruby.anno.InvokerGenerator', :classpathScope => 'compile',
#:arguments => [ '${gen.sources}/annotated_classes.txt', '${project.build.outputDirectory}' ] do
:commandlineArgs => "#{gen_sources}/annotated_classes.txt ${project.build.outputDirectory}",
:classpathScope => 'runtime', :additionalClasspathElements => [ '${project.build.outputDirectory}' ],
:includeProjectDependencies => false, :includePluginDependencies => true do
#systemProperties do
# property '-Djruby.bytecode.version=${compiler.target}'
#end
=end
execute_goal :exec, :id => 'invoker-generator', :phase => 'process-classes',
:executable => 'java', :classpathScope => 'compile',
:arguments => [ "-Djruby.bytecode.version=#{java_target}",
'-classpath', xml( '' ),
'org.jruby.anno.InvokerGenerator',
"#{gen_sources}/annotated_classes.txt",
'${project.build.outputDirectory}' ]
end
plugin( 'org.codehaus.mojo:build-helper-maven-plugin', '1.9' ) do
execute_goal 'add-source', :phase => 'process-classes', :sources => [ gen_sources ]
end
plugin( :compiler, '3.1',
:source => java_target, :target => java_target,
:encoding => 'UTF-8', :debug => true,
:showWarnings => true, :showDeprecation => true,
:generatedSourcesDirectory => gen_sources,
:annotationProcessors => [ 'org.jruby.anno.AnnotationBinder' ],
:compilerArgs => [ '-XDignore.symbol.file=true' ] ) do
#execute_goal :compile, :id => 'annotation-binder', :phase => 'compile',
# :generatedSourcesDirectory => gen_sources, #:outputDirectory => gen_sources,
# :annotationProcessors => [ 'org.jruby.anno.AnnotationBinder' ],
# :proc => 'only', # :compilerReuseStrategy => 'alwaysNew',
# :useIncrementalCompilation => false, :fork => true, :verbose => true,
# :compilerArgs => [ '-XDignore.symbol.file=true', '-J-Dfile.encoding=UTF-8' ]
execute_goal :compile, :id => 'compile-populators', :phase => 'process-classes',
:includes => [ 'org/jruby/gen/**/*.java' ], :optimize => true,
:compilerArgs => [ '-XDignore.symbol.file=true' ]
# NOTE: maybe '-J-Xbootclasspath/p:${unsafe.jar}' ... as well ?!
end
plugin! :clean, :filesets => [
{ :directory => 'lib', :includes => [ 'jopenssl.jar' ] },
{ :directory => 'lib/org' },
{ :directory => 'target', :includes => [ '*' ] },
]
# NOTE: unfortunately we can not use 1.6.8 to generate invokers ...
# although we'd like to compile against 1.6 to make sure all is well
jar 'org.jruby:jruby-core', '1.7.17', :scope => :provided # 1.6.8
jar 'junit:junit', '4.11', :scope => :test
jruby_plugin! :gem do
# when installing dependent gems we want to use the built in openssl
# not the one from this lib directory
# we compile against jruby-core-1.7.17 and want to keep this out of
# the plugin execution here
execute_goal :id => 'default-initialize', :addProjectClasspath => false, :libDirectory => 'something-which-does-not-exists'
execute_goals :id => 'default-push', :skip => true
end
# we want to have the snapshots on oss.sonatype.org and the released gems
# on maven central
plugin :deploy, '2.8.1' do
execute_goals( :deploy, :skip => false )
end
supported_bc_versions = %w{ 1.47 1.48 1.49 1.50 1.51 }
default_bc_version = File.read('lib/jopenssl/version.rb')[/BOUNCY_CASTLE_VERSION\s?=\s?'(.*?)'/, 1]
properties( 'jruby.plugins.version' => '1.0.10',
'jruby.versions' => '1.7.18',
'bc.versions' => default_bc_version,
'invoker.test' => '${bc.versions}',
# allow to skip all tests with -Dmaven.test.skip
'invoker.skip' => '${maven.test.skip}',
'runit.dir' => 'src/test/ruby/**/test_*.rb',
# use this version of jruby for ALL the jruby-maven-plugins
'jruby.version' => '1.7.18',
# dump pom.xml as readonly when running 'rmvn'
'tesla.dump.pom' => 'pom.xml',
'tesla.dump.readonly' => true )
# make sure we have the embedded jars in place before we run runit plugin
plugin! :dependency do
execute_goal 'copy-dependencies', :phase => 'generate-test-resources', :outputDirectory => '${basedir}/lib', :useRepositoryLayout => true, :includeGroupIds => 'org.bouncycastle'
end
jruby_plugin(:runit) { execute_goal( :test, :runitDirectory => '${runit.dir}' ) }
invoker_run_options = {
:id => 'tests-with-different-bc-versions',
:projectsDirectory => 'integration',
:pomIncludes => [ '*/pom.xml' ],
:streamLogs => true,
# pass those properties on to the test project
:properties => {
'jruby.versions' => '${jruby.versions}',
'jruby.modes' => '${jruby.modes}',
'jruby.openssl.version' => '${project.version}',
'bc.versions' => '${bc.versions}',
'runit.dir' => '${runit.dir}' }
}
profile :id => 'test-1.6.8' do
plugin :invoker, '1.8' do
execute_goals( :install, :run, invoker_run_options )
end
properties 'jruby.versions' => '1.6.8', 'jruby.modes' => '1.8,1.9',
'bc.versions' => supported_bc_versions.join(',')
end
profile :id => 'test-1.7.4' do
plugin :invoker, '1.8' do
execute_goals( :install, :run, invoker_run_options )
end
properties 'jruby.versions' => '1.7.4', 'jruby.modes' => '1.8,1.9',
'bc.versions' => supported_bc_versions.join(',')
end
%w{ 1.7.13 1.7.15 1.7.16 1.7.18 1.7.19 1.7.20 1.7.21 }.each { |version|
profile :id => "test-#{version}" do
plugin :invoker, '1.8' do
execute_goals( :install, :run, invoker_run_options )
end
properties 'jruby.versions' => version, 'jruby.modes' => '1.8,1.9,2.0',
'bc.versions' => supported_bc_versions.join(',')
end
}
profile :id => 'test-9000' do
plugin :invoker, '1.8' do
execute_goals( :install, :run, invoker_run_options )
end
# NOTE: we're work-around 9K maven-runit version bug (due minitest changes) !
# ... still can not build with 9K : https://github.com/jruby/jruby/issues/3184
properties 'jruby.version' => '9.0.0.0',
'jruby.versions' => '9.0.0.0',
'bc.versions' => supported_bc_versions.join(',')
end
profile :id => 'release' do
plugin :gpg, '1.5' do
execute_goal :sign, :phase => :verify
end
end
# vim: syntax=Ruby
jruby-openssl-0.9.11/README.md 0000664 0000000 0000000 00000003660 12567644621 0015717 0 ustar 00root root 0000000 0000000 # JRuby-OpenSSL
[JRuby-OpenSSL](https://github.com/jruby/jruby-openssl) is an add-on gem for
[JRuby](http://jruby.org) that emulates the Ruby OpenSSL native library.
Under the hood uses the [Bouncy Castle Crypto APIs](http://www.bouncycastle.org/).
Please report bugs and incompatibilities (preferably with test-cases) to either
the JRuby [mailing list][1] or the [bug tracker][2].
## Compatibility
Since version **0.9.5** jruby-openssl aims to be compatible with all JRuby versions
**>= 1.6.8** (including 1.7 and 9k), if it's not we consider that a bug, report.
We currently (for 0.9.x) require the Bouncy Castle Java API to be **>= 1.47**,
for JRuby-OpenSSL gem <= 0.9.6 you also need to make sure BC jars **<= 1.50** !
## Testing
[![Build Status][0]](http://travis-ci.org/jruby/jruby-openssl)
rake jar:all # creates pom.xml and generates jopenssl.jar under lib
mvn test
will run (junit as well as ruby) tests and a some ruby tests against the default
jruby version. to pick a different version and/or modes (1.8, 1.9, 2.0, 2.1) run
mvn test -Djruby.versions=1.7.12 -Djruby.modes=1.8
for running integration-tests the gem will be first installed and then the same
tests run for each possible bouncy-castle version (see [listing][3]), run with
mvn verify -P test-1.6.8,test-1.7.13
or pick a bouncy-castle version
mvn verify -P test-1.6.8 -Dbc.versions=1.50
or simply be more picky
mvn verify -P test-1.7.4 -Dbc.versions=1.49 -Djruby.modes=1.9
NOTE: you can pick any jruby version which is on [central][4] or on [ci.jruby][5]
## License
(c) 2009-2015 JRuby distributed under EPL 1.0/GPL 2.0/LGPL 2.1
[0]: https://secure.travis-ci.org/jruby/jruby-openssl.png
[1]: http://xircles.codehaus.org/projects/jruby/lists
[2]: https://github.com/jruby/jruby/issues
[3]: https://github.com/jruby/jruby-openssl/tree/master/integration
[4]: http://central.maven.org/maven2/org/jruby/
[5]: http://ci.jruby.org/snapshots/maven/org.jruby/ jruby-openssl-0.9.11/Rakefile 0000664 0000000 0000000 00000003402 12567644621 0016077 0 ustar 00root root 0000000 0000000 #-*- mode: ruby -*-
begin
require 'maven/ruby/tasks'
rescue LoadError
warn "ruby-maven not available - some tasks will not work " <<
"either `gem install ruby-maven' or use mvn instead of rake"
desc "Package jopenssl.jar with the compiled classes"
task :jar do
sh "mvn prepare-package -Dmaven.test.skip=true"
end
namespace :jar do
desc "Package jopenssl.jar file (and dependendent jars)"
task :all do
sh "mvn package -Dmaven.test.skip=true"
end
end
else
Rake::Task[:jar].clear
desc "Package jopenssl.jar with the compiled classes"
task :jar => :maven do
maven.prepare_package '-Dmaven.test.skip=true'
end
namespace :jar do
desc "Package jopenssl.jar file (and dependendent jars)"
task :all => :maven do
maven.package '-Dmaven.test.skip=true'
end
end
end
# the actual build configuration is inside the Mavenfile
task :default => :build
file('lib/jopenssl.jar') { Rake::Task['jar'].invoke }
require 'rake/testtask'
Rake::TestTask.new do |task|
task.libs << 'lib'
task.test_files = FileList['src/test/ruby/**/test*.rb']
task.verbose = true
task.loader = :direct
end
task :test => 'lib/jopenssl.jar'
namespace :integration do
it_path = File.expand_path('../src/test/integration', __FILE__)
task :install do
Dir.chdir(it_path) do
ruby "-S bundle install --gemfile '#{it_path}/Gemfile'"
end
end
# desc "Run IT tests"
task :test => 'lib/jopenssl.jar' do
unless File.exist?(File.join(it_path, 'Gemfile.lock'))
raise "bundle not installed, run `rake integration:install'"
end
loader = "ARGV.each { |f| require f }"
test_files = FileList['src/test/integration/*_test.rb'].to_a
ruby "-Ilib -e \"#{loader}\" #{test_files.map { |f| "\"#{f}\"" }.join(' ')}"
end
end jruby-openssl-0.9.11/integration/ 0000775 0000000 0000000 00000000000 12567644621 0016756 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/integration/1.47/ 0000775 0000000 0000000 00000000000 12567644621 0017347 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/integration/1.47/pom.xml 0000664 0000000 0000000 00000001050 12567644621 0020660 0 ustar 00root root 0000000 0000000
4.0.0
none
base
0
bouncy-castle
1.47
${project.version}
jruby-openssl-0.9.11/integration/1.48/ 0000775 0000000 0000000 00000000000 12567644621 0017350 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/integration/1.48/pom.xml 0000664 0000000 0000000 00000001050 12567644621 0020661 0 ustar 00root root 0000000 0000000
4.0.0
none
base
0
bouncy-castle
1.48
${project.version}
jruby-openssl-0.9.11/integration/1.49/ 0000775 0000000 0000000 00000000000 12567644621 0017351 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/integration/1.49/pom.xml 0000664 0000000 0000000 00000001050 12567644621 0020662 0 ustar 00root root 0000000 0000000
4.0.0
none
base
0
bouncy-castle
1.49
${project.version}
jruby-openssl-0.9.11/integration/1.50/ 0000775 0000000 0000000 00000000000 12567644621 0017341 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/integration/1.50/pom.xml 0000664 0000000 0000000 00000001050 12567644621 0020652 0 ustar 00root root 0000000 0000000
4.0.0
none
base
0
bouncy-castle
1.50
${project.version}
jruby-openssl-0.9.11/integration/Mavenfile 0000664 0000000 0000000 00000004133 12567644621 0020610 0 ustar 00root root 0000000 0000000 #-*- mode: ruby -*-
id 'none:base:0'
packaging :pom
snapshot_repository :id => 'jruby', :url => 'http://ci.jruby.org/snapshots/maven'
# TODO should be setup whenever a plugin uses gems
plugin_repository :id => 'rubygems-releases', :url => 'http://rubygems-proxy.torquebox.org/releases'
base_path = File.expand_path('..', File.dirname(__FILE__))
bc_version = File.read("#{base_path}/lib/jopenssl/version.rb")[/BOUNCY_CASTLE_VERSION\s?=\s?'(.*?)'/, 1]
properties( 'bc.version' => bc_version, # to satisfy maven
'jruby.openssl.version' => '0.9.7', # to satisfy maven
# use the gem-maven-plugin repo for the tests
'gem.home' => '${basedir}/../pkg/rubygems',
'gem.path' => '${basedir}/../pkg/rubygems',
'tesla.dump.pom' => 'pom.xml',
'tesla.dump.readonly' => true,
'jruby.version' => '1.7.19', # for jruby-maven-plugins
'jruby.plugins.version' => '1.0.9' )
jruby_plugin :gem, :gemHomes => { 'gem-maven-plugin' => '${gem.home}' } do
execute_goal :initialize
gem 'jar-dependencies', '0.1.8' # TODO change after 0.1.15 is out
spec = Gem::Specification.load "#{base_path}/jruby-openssl.gemspec"
spec.development_dependencies.each do |dev_spec|
gem dev_spec.name, *dev_spec.requirements_list
end
# make sure we have those in the local repo
# BUT not be part of the runit-classloader
# otherwise jruby-1.7.x and jruby-1.6.x will not use those
# required in the test_*.rb files
jar 'org.bouncycastle', 'bcpkix-jdk15on', '${bc.version}'
jar 'org.bouncycastle', 'bcprov-jdk15on', '${bc.version}'
#spec.requirements.each do |req|
# req = req.sub('jar', '').split(',').each(&:strip!)
# jar req[0], req[1]
#end
gem 'jruby-openssl', '${jruby.openssl.version}'
end
jruby_plugin :runit do
execute_goal( :test,
:env => { 'BC_VERSION' => '${bc.version}' },
:jrubySwitches => '-I../../lib',
:runitDirectory => '../../src/test/ruby/**/test_*.rb',
:versions => '${jruby.versions}',
:modes => '${jruby.modes}' )
end
# vim: syntax=Ruby
jruby-openssl-0.9.11/integration/pom.xml 0000664 0000000 0000000 00000007763 12567644621 0020310 0 ustar 00root root 0000000 0000000
4.0.0
none
base
0
pom
integration
1.7.19
true
0.9.7
${basedir}/../pkg/rubygems
1.0.9
${basedir}/../pkg/rubygems
1.50
pom.xml
false
true
jruby
http://ci.jruby.org/snapshots/maven
rubygems-releases
http://rubygems-proxy.torquebox.org/releases
de.saumya.mojo
gem-maven-plugin
${jruby.plugins.version}
initialize
rubygems
jar-dependencies
0.1.8
gem
rubygems
jar-dependencies
[0.1.0,0.1.99999]
gem
rubygems
mocha
[1.1.0,1.1.99999]
gem
rubygems
ruby-maven
[0,)
gem
org.bouncycastle
bcpkix-jdk15on
${bc.version}
org.bouncycastle
bcprov-jdk15on
${bc.version}
rubygems
jruby-openssl
${jruby.openssl.version}
gem
${gem.home}
de.saumya.mojo
runit-maven-plugin
${jruby.plugins.version}
test
${bc.version}
-I../../lib
../../src/test/ruby/**/test_*.rb
${jruby.versions}
${jruby.modes}
jruby-openssl-0.9.11/jruby-openssl.gemspec 0000664 0000000 0000000 00000002661 12567644621 0020621 0 ustar 00root root 0000000 0000000 #-*- mode: ruby -*-
Gem::Specification.new do |s|
s.name = 'jruby-openssl'
version_rb = File.expand_path('lib/jopenssl/version.rb', File.dirname(__FILE__))
version_rb = File.read(version_rb)
s.version = version_rb.match( /.*\sVERSION\s*=\s*['"](.*)['"]/ )[1]
s.platform = 'java'
s.authors = ['Ola Bini', 'JRuby contributors']
s.email = "ola.bini@gmail.com"
s.summary = "JRuby OpenSSL"
s.homepage = 'https://github.com/jruby/jruby-openssl'
s.description = 'JRuby-OpenSSL is an add-on gem for JRuby that emulates the' <<
' Ruby OpenSSL native library.'
s.licenses = [ 'EPL-1.0', 'GPL-2.0', 'LGPL-2.1' ]
s.require_paths = ['lib']
s.files = `git ls-files`.split("\n").
select { |f| f =~ /^(lib)/ || f =~ /^History|LICENSE|README|Rakefile/i } +
Dir.glob('lib/**/*.jar') # 'lib/jopenssl.jar' and potentially BC jars
bc_version = version_rb.match( /.*\sBOUNCY_CASTLE_VERSION\s*=\s*['"](.*)['"]/ )[1]
raise 'BOUNCY_CASTLE_VERSION not matched' if (bc_version || '').empty?
s.requirements << "jar org.bouncycastle:bcpkix-jdk15on, #{bc_version}"
s.requirements << "jar org.bouncycastle:bcprov-jdk15on, #{bc_version}"
s.add_development_dependency 'jar-dependencies', '~> 0.1.0'
s.add_development_dependency 'mocha', '~> 1.1.0'
s.add_development_dependency 'ruby-maven'
# NOTE: runit-maven-plugin will use it's own :
#s.add_development_dependency 'test-unit', '2.5.5'
end
# vim: syntax=Ruby jruby-openssl-0.9.11/lib/ 0000775 0000000 0000000 00000000000 12567644621 0015201 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/lib/jopenssl/ 0000775 0000000 0000000 00000000000 12567644621 0017036 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/lib/jopenssl/load.rb 0000664 0000000 0000000 00000002167 12567644621 0020310 0 ustar 00root root 0000000 0000000 warn 'Loading jruby-openssl in a non-JRuby interpreter' unless defined? JRUBY_VERSION
require 'java'
require 'jopenssl/version'
# NOTE: assuming user does pull in BC .jars from somewhere else on the CP
unless ENV_JAVA['jruby.openssl.load.jars'].eql?('false')
version = Jopenssl::Version::BOUNCY_CASTLE_VERSION
bc_jars = nil
begin
# if we have jar-dependencies we let it track the jars
require_jar( 'org.bouncycastle', 'bcpkix-jdk15on', version )
require_jar( 'org.bouncycastle', 'bcprov-jdk15on', version )
bc_jars = true
rescue LoadError
end if defined?(Jars) && ( ! Jars.skip? ) rescue nil
unless bc_jars
load "org/bouncycastle/bcpkix-jdk15on/#{version}/bcpkix-jdk15on-#{version}.jar"
load "org/bouncycastle/bcprov-jdk15on/#{version}/bcprov-jdk15on-#{version}.jar"
end
end
require 'jruby'
require 'jopenssl.jar'
org.jruby.ext.openssl.OpenSSL.load(JRuby.runtime)
if RUBY_VERSION > '2.2'
load 'jopenssl22/openssl.rb'
elsif RUBY_VERSION > '2.1'
load 'jopenssl21/openssl.rb'
elsif RUBY_VERSION > '1.9'
load 'jopenssl19/openssl.rb'
else
load 'jopenssl18/openssl.rb'
end
require 'openssl/pkcs12'
jruby-openssl-0.9.11/lib/jopenssl/version.rb 0000664 0000000 0000000 00000000145 12567644621 0021050 0 ustar 00root root 0000000 0000000 module Jopenssl
module Version
VERSION = '0.9.11'
BOUNCY_CASTLE_VERSION = '1.50'
end
end
jruby-openssl-0.9.11/lib/jopenssl18/ 0000775 0000000 0000000 00000000000 12567644621 0017207 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/lib/jopenssl18/openssl.rb 0000664 0000000 0000000 00000001052 12567644621 0021215 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id: openssl.rb 12496 2007-06-08 15:02:04Z technorama $
=end
require 'openssl/bn'
require 'openssl/cipher'
require 'openssl/config'
require 'openssl/digest'
require 'openssl/pkcs7'
require 'openssl/ssl-internal'
require 'openssl/x509-internal'
jruby-openssl-0.9.11/lib/jopenssl18/openssl/ 0000775 0000000 0000000 00000000000 12567644621 0020672 5 ustar 00root root 0000000 0000000 jruby-openssl-0.9.11/lib/jopenssl18/openssl/bn.rb 0000664 0000000 0000000 00000000676 12567644621 0021627 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id$
=end
##
# Add double dispatch to Integer
#
class Integer
def to_bn
OpenSSL::BN::new(self.to_s(16), 16)
end
end # Integer
jruby-openssl-0.9.11/lib/jopenssl18/openssl/buffering.rb 0000664 0000000 0000000 00000007257 12567644621 0023201 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- Buffering mix-in module.
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2001 GOTOU YUUZOU
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id$
=end
module OpenSSL
module Buffering
include Enumerable
attr_accessor :sync
BLOCK_SIZE = 1024*16
def initialize(*args)
@eof = false
@rbuffer = ""
@sync = @io.sync
end
#
# for reading.
#
private
def fill_rbuff
begin
@rbuffer << self.sysread(BLOCK_SIZE)
rescue Errno::EAGAIN
retry
rescue EOFError
@eof = true
end
end
def consume_rbuff(size=nil)
if @rbuffer.empty?
nil
else
size = @rbuffer.size unless size
ret = @rbuffer[0, size]
@rbuffer[0, size] = ""
ret
end
end
public
def read(size=nil, buf=nil)
if size == 0
if buf
buf.clear
else
buf = ""
end
return @eof ? nil : buf
end
until @eof
break if size && size <= @rbuffer.size
fill_rbuff
end
ret = consume_rbuff(size) || ""
if buf
buf.replace(ret)
ret = buf
end
(size && ret.empty?) ? nil : ret
end
def readpartial(maxlen, buf=nil)
if maxlen == 0
if buf
buf.clear
else
buf = ""
end
return @eof ? nil : buf
end
if @rbuffer.empty?
begin
return sysread(maxlen, buf)
rescue Errno::EAGAIN
retry
end
end
ret = consume_rbuff(maxlen)
if buf
buf.replace(ret)
ret = buf
end
raise EOFError if ret.empty?
ret
end
def gets(eol=$/)
idx = @rbuffer.index(eol)
until @eof
break if idx
fill_rbuff
idx = @rbuffer.index(eol)
end
if eol.is_a?(Regexp)
size = idx ? idx+$&.size : nil
else
size = idx ? idx+eol.size : nil
end
consume_rbuff(size)
end
def each(eol=$/)
while line = self.gets(eol)
yield line
end
end
alias each_line each
def readlines(eol=$/)
ary = []
while line = self.gets(eol)
ary << line
end
ary
end
def readline(eol=$/)
raise EOFError if eof?
gets(eol)
end
def getc
c = read(1)
c ? c[0] : nil
end
def each_byte
while c = getc
yield(c)
end
end
def readchar
raise EOFError if eof?
getc
end
def ungetc(c)
@rbuffer[0,0] = c.chr
end
def eof?
fill_rbuff if !@eof && @rbuffer.empty?
@eof && @rbuffer.empty?
end
alias eof eof?
#
# for writing.
#
private
def do_write(s)
@wbuffer = "" unless defined? @wbuffer
@wbuffer << s
@sync ||= false
if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
remain = idx ? idx + $/.size : @wbuffer.length
nwritten = 0
while remain > 0
str = @wbuffer[nwritten,remain]
begin
nwrote = syswrite(str)
rescue Errno::EAGAIN
retry
end
remain -= nwrote
nwritten += nwrote
end
@wbuffer[0,nwritten] = ""
end
end
public
def write(s)
do_write(s)
s.length
end
def << (s)
do_write(s)
self
end
def puts(*args)
s = ""
if args.empty?
s << "\n"
end
args.each{|arg|
s << arg.to_s
if $/ && /\n\z/ !~ s
s << "\n"
end
}
do_write(s)
nil
end
def print(*args)
s = ""
args.each{ |arg| s << arg.to_s }
do_write(s)
nil
end
def printf(s, *args)
do_write(s % args)
nil
end
def flush
osync = @sync
@sync = true
do_write ""
@sync = osync
end
def close
flush rescue nil
sysclose
end
end
end
jruby-openssl-0.9.11/lib/jopenssl18/openssl/cipher.rb 0000664 0000000 0000000 00000001126 12567644621 0022471 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- Ruby-space predefined Cipher subclasses
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id$
=end
##
# Should we care what if somebody require this file directly?
#require 'openssl'
module OpenSSL
class Cipher
# This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
class Cipher < Cipher
# add warning
end
end # Cipher
end # OpenSSL jruby-openssl-0.9.11/lib/jopenssl18/openssl/config.rb 0000664 0000000 0000000 00000016514 12567644621 0022473 0 ustar 00root root 0000000 0000000 =begin
= Ruby-space definitions that completes C-space funcs for Config
= Info
Copyright (C) 2010 Hiroshi Nakamura
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
=end
##
# Should we care what if somebody require this file directly?
#require 'openssl'
require 'stringio'
module OpenSSL
class Config
include Enumerable
class << self
def parse(str)
c = new()
parse_config(StringIO.new(str)).each do |section, hash|
c[section] = hash
end
c
end
alias load new
def parse_config(io)
begin
parse_config_lines(io)
rescue ConfigError => e
e.message.replace("error in line #{io.lineno}: " + e.message)
raise
end
end
def get_key_string(data, section, key) # :nodoc:
if v = data[section] && data[section][key]
return v
elsif section == 'ENV'
if v = ENV[key]
return v
end
end
if v = data['default'] && data['default'][key]
return v
end
end
private
def parse_config_lines(io)
section = 'default'
data = {section => {}}
while definition = get_definition(io)
definition = clear_comments(definition)
next if definition.empty?
if definition[0] == ?[
if /\[([^\]]*)\]/ =~ definition
section = $1.strip
data[section] ||= {}
else
raise ConfigError, "missing close square bracket"
end
else
if /\A([^:\s]*)(?:::([^:\s]*))?\s*=(.*)\z/ =~ definition
if $2
section = $1
key = $2
else
key = $1
end
value = unescape_value(data, section, $3)
(data[section] ||= {})[key] = value.strip
else
raise ConfigError, "missing equal sign"
end
end
end
data
end
# escape with backslash
QUOTE_REGEXP_SQ = /\A([^'\\]*(?:\\.[^'\\]*)*)'/
# escape with backslash and doubled dq
QUOTE_REGEXP_DQ = /\A([^"\\]*(?:""[^"\\]*|\\.[^"\\]*)*)"/
# escaped char map
ESCAPE_MAP = {
"r" => "\r",
"n" => "\n",
"b" => "\b",
"t" => "\t",
}
def unescape_value(data, section, value)
scanned = []
while m = value.match(/['"\\$]/)
scanned << m.pre_match
c = m[0]
value = m.post_match
case c
when "'"
if m = value.match(QUOTE_REGEXP_SQ)
scanned << m[1].gsub(/\\(.)/, '\\1')
value = m.post_match
else
break
end
when '"'
if m = value.match(QUOTE_REGEXP_DQ)
scanned << m[1].gsub(/""/, '').gsub(/\\(.)/, '\\1')
value = m.post_match
else
break
end
when "\\"
c = value.slice!(0, 1)
scanned << (ESCAPE_MAP[c] || c)
when "$"
ref, value = extract_reference(value)
refsec = section
if ref.index('::')
refsec, ref = ref.split('::', 2)
end
if v = get_key_string(data, refsec, ref)
scanned << v
else
raise ConfigError, "variable has no value"
end
else
raise 'must not reaced'
end
end
scanned << value
scanned.join
end
def extract_reference(value)
rest = ''
if m = value.match(/\(([^)]*)\)|\{([^}]*)\}/)
value = m[1] || m[2]
rest = m.post_match
elsif [?(, ?{].include?(value[0])
raise ConfigError, "no close brace"
end
if m = value.match(/[a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]*)?/)
return m[0], m.post_match + rest
else
raise
end
end
def clear_comments(line)
# FCOMMENT
if m = line.match(/\A([\t\n\f ]*);.*\z/)
return m[1]
end
# COMMENT
scanned = []
while m = line.match(/[#'"\\]/)
scanned << m.pre_match
c = m[0]
line = m.post_match
case c
when '#'
line = nil
break
when "'", '"'
regexp = (c == "'") ? QUOTE_REGEXP_SQ : QUOTE_REGEXP_DQ
scanned << c
if m = line.match(regexp)
scanned << m[0]
line = m.post_match
else
scanned << line
line = nil
break
end
when "\\"
scanned << c
scanned << line.slice!(0, 1)
else
raise 'must not reaced'
end
end
scanned << line
scanned.join
end
def get_definition(io)
if line = get_line(io)
while /[^\\]\\\z/ =~ line
if extra = get_line(io)
line += extra
else
break
end
end
return line.strip
end
end
def get_line(io)
if line = io.gets
line.gsub(/[\r\n]*/, '')
end
end
end
def initialize(filename = nil)
@data = {}
if filename
File.open(filename.to_s) do |file|
Config.parse_config(file).each do |section, hash|
self[section] = hash
end
end
end
end
def get_value(section, key)
if section.nil?
raise TypeError.new('nil not allowed')
end
section = 'default' if section.empty?
get_key_string(section, key)
end
def value(arg1, arg2 = nil)
warn('Config#value is deprecated; use Config#get_value')
if arg2.nil?
section, key = 'default', arg1
else
section, key = arg1, arg2
end
section ||= 'default'
section = 'default' if section.empty?
get_key_string(section, key)
end
def add_value(section, key, value)
check_modify
(@data[section] ||= {})[key] = value
end
def [](section)
@data[section] || {}
end
def section(name)
warn('Config#section is deprecated; use Config#[]')
@data[name] || {}
end
def []=(section, pairs)
check_modify
@data[section] ||= {}
pairs.each do |key, value|
self.add_value(section, key, value)
end
end
def sections
@data.keys
end
def to_s
ary = []
@data.keys.sort.each do |section|
ary << "[ #{section} ]\n"
@data[section].keys.each do |key|
ary << "#{key}=#{@data[section][key]}\n"
end
ary << "\n"
end
ary.join
end
def each
@data.each do |section, hash|
hash.each do |key, value|
yield(section, key, value)
end
end
end
def inspect
"#<#{self.class.name} sections=#{sections.inspect}>"
end
protected
def data
@data
end
private
def initialize_copy(other)
@data = other.data.dup
end
def check_modify
raise TypeError.new("Insecure: can't modify OpenSSL config") if frozen?
end
def get_key_string(section, key)
Config.get_key_string(@data, section, key)
end
end
end
jruby-openssl-0.9.11/lib/jopenssl18/openssl/digest.rb 0000664 0000000 0000000 00000001225 12567644621 0022476 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- Ruby-space predefined Digest subclasses
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id$
=end
##
# Should we care what if somebody require this file directly?
#require 'openssl'
module OpenSSL
class Digest
# This class is only provided for backwards compatibility. Use OpenSSL::Digest in the future.
class Digest < Digest
def initialize(*args)
# add warning
super(*args)
end
end
end # Digest
end # OpenSSL
jruby-openssl-0.9.11/lib/jopenssl18/openssl/pkcs7.rb 0000664 0000000 0000000 00000001051 12567644621 0022243 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- PKCS7
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id: digest.rb 12148 2007-04-05 05:59:22Z technorama $
=end
module OpenSSL
class PKCS7
# This class is only provided for backwards compatibility. Use OpenSSL::PKCS7 in the future.
class PKCS7 < PKCS7
def initialize(*args)
super(*args)
warn("Warning: OpenSSL::PKCS7::PKCS7 is deprecated after Ruby 1.9; use OpenSSL::PKCS7 instead")
end
end
end # PKCS7
end # OpenSSL
jruby-openssl-0.9.11/lib/jopenssl18/openssl/ssl-internal.rb 0000664 0000000 0000000 00000005435 12567644621 0023641 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2001 GOTOU YUUZOU
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id$
=end
require "openssl/buffering"
require 'fcntl' # used by OpenSSL::SSL::Nonblock (if loaded)
module OpenSSL
module SSL
def verify_certificate_identity(cert, hostname)
should_verify_common_name = true
cert.extensions.each{|ext|
next if ext.oid != "subjectAltName"
ext.value.split(/,\s+/).each{|general_name|
if /\ADNS:(.*)/ =~ general_name
should_verify_common_name = false
reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+")
return true if /\A#{reg}\z/i =~ hostname
# NOTE: somehow we need the IP: canonical form
# seems there were failures elsewhere when not
# not sure how that's possible possible to-do!
elsif /\AIP(?: Address)?:(.*)/ =~ general_name
#elsif /\AIP Address:(.*)/ =~ general_name
should_verify_common_name = false
return true if $1 == hostname
end
}
}
if should_verify_common_name
cert.subject.to_a.each{|oid, value|
if oid == "CN"
reg = Regexp.escape(value).gsub(/\\\*/, "[^.]+")
return true if /\A#{reg}\z/i =~ hostname
end
}
end
return false
end
module_function :verify_certificate_identity
class SSLSocket
include Buffering
include SocketForwarder
include Nonblock
def post_connection_check(hostname)
unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
raise SSLError, "hostname was not match with the server certificate"
end
return true
end
end
class SSLServer
include SocketForwarder
attr_accessor :start_immediately
def initialize(svr, ctx)
@svr = svr
@ctx = ctx
unless ctx.session_id_context
session_id = OpenSSL::Digest::MD5.hexdigest($0)
@ctx.session_id_context = session_id
end
@start_immediately = true
end
def to_io
@svr
end
def listen(backlog=5)
@svr.listen(backlog)
end
def shutdown(how=Socket::SHUT_RDWR)
@svr.shutdown(how)
end
def accept
sock = @svr.accept
begin
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
ssl.sync_close = true
ssl.accept if @start_immediately
ssl
rescue SSLError => ex
sock.close
raise ex
end
end
def close
@svr.close
end
end
end
end
jruby-openssl-0.9.11/lib/jopenssl18/openssl/ssl.rb 0000664 0000000 0000000 00000000022 12567644621 0022012 0 ustar 00root root 0000000 0000000 require 'openssl'
jruby-openssl-0.9.11/lib/jopenssl18/openssl/x509-internal.rb 0000664 0000000 0000000 00000006242 12567644621 0023542 0 ustar 00root root 0000000 0000000 =begin
= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
= Info
'OpenSSL for Ruby 2' project
Copyright (C) 2002 Michal Rokos
All rights reserved.
= Licence
This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)
= Version
$Id$
=end
module OpenSSL
module X509
class Name
module RFC2253DN
Special = ',=+<>#;'
HexChar = /[0-9a-fA-F]/
HexPair = /#{HexChar}#{HexChar}/
HexString = /#{HexPair}+/
Pair = /\\(?:[#{Special}]|\\|"|#{HexPair})/
StringChar = /[^#{Special}\\"]/
QuoteChar = /[^\\"]/
AttributeType = /[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
AttributeValue = /
(?!["#])((?:#{StringChar}|#{Pair})*)|
\#(#{HexString})|
"((?:#{QuoteChar}|#{Pair})*)"
/x
TypeAndValue = /\A(#{AttributeType})=#{AttributeValue}/
module_function
def expand_pair(str)
return nil unless str
return str.gsub(Pair){
pair = $&
case pair.size
when 2 then pair[1,1]
when 3 then Integer("0x#{pair[1,2]}").chr
else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
end
}
end
def expand_hexstring(str)
return nil unless str
der = str.gsub(HexPair){$&.to_i(16).chr }
a1 = OpenSSL::ASN1.decode(der)
return a1.value, a1.tag
end
def expand_value(str1, str2, str3)
value = expand_pair(str1)
value, tag = expand_hexstring(str2) unless value
value = expand_pair(str3) unless value
return value, tag
end
def scan(dn)
str = dn
ary = []
while true
if md = TypeAndValue.match(str)
matched = md.to_s
remain = md.post_match
type = md[1]
value, tag = expand_value(md[2], md[3], md[4]) rescue nil
if value
type_and_value = [type, value]
type_and_value.push(tag) if tag
ary.unshift(type_and_value)
if remain.length > 2 && remain[0] == ?,
str = remain[1..-1]
next
elsif remain.length > 2 && remain[0] == ?+
raise OpenSSL::X509::NameError,
"multi-valued RDN is not supported: #{dn}"
elsif remain.empty?
break
end
end
end
msg_dn = dn[0, dn.length - str.length] + " =>" + str
raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
end
return ary
end
end
class <