Skip to content

Feature | client certificate authentication#1284

Merged
peterbae merged 61 commits intomicrosoft:devfrom
peterbae:clientcertauth
Mar 27, 2020
Merged

Feature | client certificate authentication#1284
peterbae merged 61 commits intomicrosoft:devfrom
peterbae:clientcertauth

Conversation

@peterbae
Copy link
Copy Markdown
Contributor

The JDBC driver will add three connection properties for this feature:

clientCertificate – specifies the certificate to be used for authentication. The JDBC driver will support PFX, PEM, DER and CER file extensions. Format:
• clientCertificate=<file_location>
The driver uses a certificate file. For certificates in PEM, DER and CER formats clientKey attribute is required.

clientKey – specifies a file location of the private key for PEM, DER and CER certificates specified by the clientCertificate attribute. Format:
• clientKey=<file_location>
Specifies location of the private key file. In case if private key file is password protected then password keyword is required.
clientKeyPassword – optional password string provided to access the clientKey file’s private key.

lilgreenbird and others added 27 commits February 5, 2020 11:03
…ed by default (microsoft#1254)

* skip AKV test properly

* removed enclave properties string to failed errors as enclave tests could be skipped
Add support for PKCS8 and PKCS1 private keys
change logic for decryptprovider
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java Outdated
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
+ ";";
try (Connection conn = DriverManager.getConnection(conStr)) {
} catch (SQLServerException e) {
assertTrue(e.getMessage().contains(TestResource.getResource("R_invalidPath")));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use R_clientCertError from SQLServerResource.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQLServerResource is not visible in this package, we can just use the TestResource for test related texts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See SQLServerConnectionTest.executeInvalidFmt() for example use.

assertTrue(e.getMessage().matches(TestUtils.formatErrorMsg("R_invalidArgument")));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. done.


@Test
public void testDataSource() throws Exception {
String conStr = connectionString + ";clientCertificate=" + clientCertificate + ".pem;" + "clientKey="
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't you using new DataSource APIs? setClientCertificate(), setClientKey(), setClientKeyPassword

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Public API Changes in Public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants