Reputation: 2911
I have a java complied package to speak with the https server on net. Running the compilation gives the following exception:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
I think this is due to the connection established with the client machine is not secure. Is there any way to configure the local machine or ports in order to connect to the remote https server?
Upvotes: 234
Views: 765076
Reputation: 466
I've stumbled upon this issue while testing a Spring Boot API in Tomcat (in a local setup).
In the application's config.properties
file (which is the file we're using to configure some external URLs & endpoints) some of them were defined with https
instead of http
(for development environment we were mocking these 3rd party APIs through Postman / SOAPUI).
The issue was resolved by changing the https
to http
on those endpoints and restarting Tomcat.
Upvotes: 1
Reputation: 1121
In case you use Jetty version 9 or earlier you need to add it to jetty by
RUN java -jar ${JETTY_HOME}/start.jar --add-to-startd=https
and according to this Jetty: How to use SSL in Jetty client side
from Jetty version 10 it should work out of the box
Upvotes: 0
Reputation: 76
If you are running local using spring i'd suggest use:
@Bean
public AmazonDynamoDB amazonDynamoDB() throws IOException {
return AmazonDynamoDBClientBuilder.standard()
.withCredentials(
new AWSStaticCredentialsProvider(
new BasicAWSCredentials("fake", "credencial")
)
)
.withClientConfiguration(new ClientConfigurationFactory().getConfig().withProtocol(Protocol.HTTP))
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("localhost:8443", "central"))
.build();
}
It works for me using unit test.
Hope it's help!
Upvotes: 1
Reputation: 1452
I've got similar error using camel-mail component to send e-mails by gmail smtp.
The solution was changing from TLS port (587) to SSL port (465) as below:
<route id="sendMail">
<from uri="jason:toEmail"/>
<convertBodyTo type="java.lang.String"/>
<setHeader headerName="Subject"><constant>Something</constant></setHeader>
<to uri="smtps://smtp.gmail.com:465?username=myemail@gmail.com&password=mypw&to=someemail@gmail.com&debugMode=true&mail.smtp.starttls.enable=true"/>
</route>
Upvotes: -1
Reputation: 1787
i solved my problem using port 25 and Following prop
mailSender.javaMailProperties.putAll([
"mail.smtp.auth": "true",
"mail.smtp.starttls.enable": "false",
"mail.smtp.ssl.enable": "false",
"mail.smtp.socketFactory.fallback": "true",
]);
Upvotes: 0
Reputation: 478
I was facing this exception when using Gmail.
In order to use Gmail I had to turn ON "Allow less secure apps".
This Gmail setting can be found at https://www.google.com/settings/security/lesssecureapps after login the gmail account.
Upvotes: -1
Reputation: 517
if connection is FTPS test:
FTPSClient ftpClient = new FTPSClient(protocol, false);
protocol = TLS,SSL and false = isImplicit.
Upvotes: -1
Reputation: 4847
Adding this as an answer as it might help someone later.
I had to force jvm to use the IPv4 stack to resolve the error. My application used to work within company network, but while connecting from home it gave the same exception. No proxy involved. Added the jvm argument
-Djava.net.preferIPv4Stack=true
and all the https
requests were behaving normally.
Upvotes: 2
Reputation: 247
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
You should have a local SMTP domain name that will contact the mail server and establishes a new connection as well you should change the SSL property in your programming below
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection
props.put("mail.smtp.socketFactory.fallback", "true"); // Should be true
Upvotes: 22
Reputation: 311048
I think this is due to the connection established with the client machine is not secure.
It is due to the fact that you are talking to an HTTP server, not an HTTPS server. Probably you didn't use the correct port number for HTTPS.
Upvotes: 329
Reputation: 1264
I face the same issue from Java application built in Jdevelopr 11.1.1.7 IDE. I solved the issue by unchecking the use of proxy form Project properties.
You can find it in the following: Project Properties -> (from left panle )Run/Debug/Profile ->Click (edit) form the right panel -> Tool Setting from the left panel -> uncheck (Use Proxy) option.
Upvotes: 0
Reputation: 1340
I got the same error. it was because I was accessing the https port using http.. The issue solved when I changed http to https.
Upvotes: 5
Reputation: 568
I got the same error message when I forgot to log in to the company firewall, before performing a POST request through a proxy.
Upvotes: 12