Details
-
Bug
-
Resolution: Unresolved
-
Test Blocker
-
tech-debt
Description
Currently there is no documentation on how to add a predefined certificate in Dot Net.
While it looks possible, it is not the most straight forward.
in the API i found that class for it: PredefinedCertificateFactory using that dot net class: X509Certificate2
Please add a description on how to add certificate to the code, as some users do need it.
Possible way of doing it:
String stringCert= "-----BEGIN CERTIFICATE-----\n" + |
<SNIP>
|
"-----END CERTIFICATE-----\n"; |
X509Certificate2 cert= new X509Certificate2(Encoding.UTF8.GetBytes(stringCert)); |
PredefinedCertificateFactory factory = new PredefinedCertificateFactory([cert]); |
|
var options = new ClusterOptions |
{
|
EnableTls= true, |
KvIgnoreRemoteCertificateNameMismatch=true, |
UserName = "Administrator", |
Password = "password", |
}.WithX509CertificateFactory(factory);
|
*please verify with Engineering.
note: Java doesn't have that either, in Java this is the code needed:
X509Certificate cert = new LazyX509Certificate( |
new String("-----BEGIN CERTIFICATE-----\n" + |
<SNIP>
|
"-----END CERTIFICATE-----\n").getBytes()); |
|
ClusterEnvironment env = ClusterEnvironment.builder()
|
.securityConfig(SecurityConfig.enableTls(true) |
.enableHostnameVerification(false) |
.trustCertificates(Arrays.asList((cert))))
|
.build();
|
Browser environment: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Reporter: Roi Katz
E-mail: roi.katz@couchbase.com