Skip to content

Can't have both SSL enabled and a custom SocketFactory #5099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ddossot opened this issue Feb 6, 2016 · 4 comments
Closed

Can't have both SSL enabled and a custom SocketFactory #5099

ddossot opened this issue Feb 6, 2016 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@ddossot
Copy link

ddossot commented Feb 6, 2016

Using spring-boot 1.3.2.RELEASE and mongo-java-driver 3.2.1 and this code:

@Bean
public MongoClientOptions mongoClientOptions() {
    return MongoClientOptions.builder().sslEnabled(true).socketFactory(mySF).build();
}
  • If spring.data.mongodb.uri has ssl=true, then SSL is activated in MongoClient but mySF is not used,
  • if spring.data.mongodb.uri doesn't have ssl=true, then SSL is not activated in MongoClient but mySF is used.

This is because the logics in MongoProperties.createMongoClient and MongoClientOptions.Builder.sslEnabled fight each other:

  • the sslEnabled(true) bit in my code above is basically a no-op because createMongoClient assumes that ssl=true option will be set in the URI, and thus doesn't try to carry the value set on the builder,
  • the socketFactory(mySF) is a no-op if ssl=true in the URI because sslEnabled wipes out the value in the builder with a default SSLSocketFactory.

So I'm kind of stuck between a rock and a hard place 😅 Any suggestion would be appreciated.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 6, 2016
@philwebb
Copy link
Member

philwebb commented Feb 8, 2016

It looks like sslEnabled was added in Mongo 3.0 and we're currently building against mongo 2.13.x. I'm guessing we probably need to update the MongoProperties.builder() method to try and set properties via reflection.

For now, your best option is to probably take complete control of creating the Mongo @Bean so that our auto-configuration doesn't get involved.

@philwebb philwebb removed the status: waiting-for-triage An issue we've not yet triaged label Feb 8, 2016
@philwebb philwebb added this to the 1.4.0.M1 milestone Feb 8, 2016
@ddossot
Copy link
Author

ddossot commented Feb 8, 2016

Thank you for the quick response and suggestion.

@philwebb philwebb modified the milestones: 1.4.0.M2, 1.4.0.M1 Feb 26, 2016
@philwebb philwebb modified the milestones: 1.4.0.M3, 1.4.0.M2 Apr 12, 2016
@philwebb philwebb modified the milestones: 1.4.0.RC1, 1.4.0.M3 May 17, 2016
@snicoll
Copy link
Member

snicoll commented Jun 17, 2016

When you set ssl=true (or ssl=false) in the URI, it will reset to SocketFactory and there is not much we can do about that. I've created JAVA-2229 to track this problem (maybe we're doing something wrong there though).

We're compiling against 3.x now so I'll make sure the second case works.

@snicoll snicoll self-assigned this Jun 17, 2016
@snicoll snicoll added the type: bug A general bug label Jun 17, 2016
@jyemin
Copy link

jyemin commented Jun 17, 2016

I'm looking at JAVA-2229 and will suggest options. Currently I don't see a workaround, and so we'll need to do a release to address the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants