Skip to content

Commit 34eb055

Browse files
Merge branch 'master' into rabbitmq-server-505
2 parents a3f0c28 + 4fc1bbb commit 34eb055

File tree

6 files changed

+99
-3
lines changed

6 files changed

+99
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ These versions can still be used with RabbitMQ server `3.x`.
2323
<dependency>
2424
<groupId>com.rabbitmq</groupId>
2525
<artifactId>amqp-client</artifactId>
26-
<version>4.0.0</version>
26+
<version>4.0.1</version>
2727
</dependency>
2828
```
2929

3030
### Gradle
3131

3232
``` groovy
33-
compile 'com.rabbitmq:amqp-client:4.0.0'
33+
compile 'com.rabbitmq:amqp-client:4.0.1'
3434
```
3535

3636
#### 3.6.x Series

src/main/java/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public void useSslProtocol()
576576
public void useSslProtocol(String protocol)
577577
throws NoSuchAlgorithmException, KeyManagementException
578578
{
579-
useSslProtocol(protocol, new NullTrustManager());
579+
useSslProtocol(protocol, new TrustEverythingTrustManager());
580580
}
581581

582582
/**

src/main/java/com/rabbitmq/client/NullTrustManager.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,31 @@
1616

1717
package com.rabbitmq.client;
1818

19+
import org.slf4j.LoggerFactory;
20+
1921
import java.security.cert.X509Certificate;
2022

2123
import javax.net.ssl.X509TrustManager;
2224

2325
/**
2426
* Convenience class providing a default implementation of javax.net.ssl.X509TrustManager.
2527
* Trusts every single certificate presented to it.
28+
*
29+
* Deprecated, use {@link TrustEverythingTrustManager} instead.
30+
* Will be removed in next major release.
31+
*
32+
* @deprecated
2633
*/
2734
public class NullTrustManager implements X509TrustManager {
35+
36+
public NullTrustManager() {
37+
LoggerFactory.getLogger(NullTrustManager.class).warn(
38+
"This trust manager trusts every certificate, effectively disabling peer verification. " +
39+
"This is convenient for local development but prone to man-in-the-middle attacks. " +
40+
"Please see http://www.rabbitmq.com/ssl.html#validating-cerficates to learn more about peer certificate validation."
41+
);
42+
}
43+
2844
/**
2945
* Doesn't even bother looking at its arguments, simply returns,
3046
* which makes the check succeed.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2007-Present Pivotal Software, Inc. All rights reserved.
2+
//
3+
// This software, the RabbitMQ Java client library, is triple-licensed under the
4+
// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2
5+
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see
6+
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL,
7+
// please see LICENSE-APACHE2.
8+
//
9+
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
10+
// either express or implied. See the LICENSE file for specific language governing
11+
// rights and limitations of this software.
12+
//
13+
// If you have any questions regarding licensing, please contact us at
14+
15+
16+
17+
package com.rabbitmq.client;
18+
19+
import org.slf4j.LoggerFactory;
20+
21+
import javax.net.ssl.X509TrustManager;
22+
import java.security.cert.X509Certificate;
23+
24+
/**
25+
* Convenience class providing a default implementation of javax.net.ssl.X509TrustManager.
26+
* Trusts every single certificate presented to it.
27+
*/
28+
public class TrustEverythingTrustManager implements X509TrustManager {
29+
30+
public TrustEverythingTrustManager() {
31+
LoggerFactory.getLogger(TrustEverythingTrustManager.class).warn(
32+
"This trust manager trusts every certificate, effectively disabling peer verification. " +
33+
"This is convenient for local development but prone to man-in-the-middle attacks. " +
34+
"Please see http://www.rabbitmq.com/ssl.html#validating-cerficates to learn more about peer certificate validation."
35+
);
36+
}
37+
38+
/**
39+
* Doesn't even bother looking at its arguments, simply returns,
40+
* which makes the check succeed.
41+
*/
42+
@Override
43+
public void checkClientTrusted(X509Certificate[] chain, String authType) {
44+
// Do nothing.
45+
}
46+
47+
/**
48+
* Doesn't even bother looking at its arguments, simply returns,
49+
* which makes the check succeed.
50+
*/
51+
@Override
52+
public void checkServerTrusted(X509Certificate[] chain, String authType) {
53+
// Do nothing.
54+
}
55+
56+
/**
57+
* Always returns an empty array of X509Certificates.
58+
*/
59+
@Override
60+
public X509Certificate[] getAcceptedIssuers() {
61+
return new X509Certificate[0];
62+
}
63+
}

src/test/java/com/rabbitmq/client/test/BrokerTestCase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.rabbitmq.client.test;
1818

1919
import com.rabbitmq.client.*;
20+
import com.rabbitmq.client.impl.nio.NioParams;
2021
import com.rabbitmq.tools.Host;
2122
import org.junit.After;
2223
import org.junit.Before;
@@ -60,10 +61,17 @@ protected void finished(Description description) {
6061

6162
protected ConnectionFactory newConnectionFactory() {
6263
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
64+
if(TestUtils.USE_NIO) {
65+
connectionFactory.setNioParams(nioParams());
66+
}
6367
connectionFactory.setAutomaticRecoveryEnabled(isAutomaticRecoveryEnabled());
6468
return connectionFactory;
6569
}
6670

71+
protected NioParams nioParams() {
72+
return new NioParams();
73+
}
74+
6775
protected boolean isAutomaticRecoveryEnabled() {
6876
return true;
6977
}

src/test/java/com/rabbitmq/client/test/server/PersistenceGuarantees.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.IOException;
2121

22+
import com.rabbitmq.client.impl.nio.NioParams;
2223
import org.junit.Test;
2324

2425
import com.rabbitmq.client.MessageProperties;
@@ -28,6 +29,14 @@ public class PersistenceGuarantees extends BrokerTestCase {
2829
private static final int COUNT = 10000;
2930
private String queue;
3031

32+
@Override
33+
protected NioParams nioParams() {
34+
NioParams nioParams = super.nioParams();
35+
// may need a higher enqueuing timeout on slow environments
36+
return nioParams
37+
.setWriteEnqueuingTimeoutInMs(nioParams.getWriteEnqueuingTimeoutInMs() * 2);
38+
}
39+
3140
protected void declareQueue() throws IOException {
3241
queue = channel.queueDeclare("", true, false, false, null).getQueue();
3342
}

0 commit comments

Comments
 (0)