Method to store X509 certificate from Database

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












I've a method that gets certificate as BLOB and password as char from Oracle Database, store this certificate x509, trust it, get the secure connection and verify Hostname.



This is the code:



public void openCert() throws Exception CertificateException e) 
this.Message = "Err.openCert: ";
throw new Exception(this.Message + e);
catch (SQLException e)
this.Message = "Err.openCert.getCert["+line+"]: ";
throw new Exception(this.Message + e);
catch (Exception e)
this.Message = "Err.openCert.UncaughtException: ";
throw new Exception(this.Message + e);
finally
if(conn != null)
conn.close();





Do you have any idea to how improve the code and refactor it?







share|improve this question













migrated from stackoverflow.com May 15 at 20:58


This question came from our site for professional and enthusiast programmers.














  • There is no key pair here, ergo no keystore either, only a truststore. You aren't checking the value of resultSet.next(). Off topic.
    – user207421
    May 14 at 16:34










  • What is a Conexion?
    – 200_success
    May 15 at 22:38










  • Conexión is a class that extends Connection and do more things, works like Connetion class and take DB connection from a .properties.
    – Rancio
    May 16 at 5:45










  • I don't get what the use of the HostnameVerifier empty if statement is..Seems broken code?
    – RobAu
    May 17 at 8:30
















up vote
0
down vote

favorite












I've a method that gets certificate as BLOB and password as char from Oracle Database, store this certificate x509, trust it, get the secure connection and verify Hostname.



This is the code:



public void openCert() throws Exception CertificateException e) 
this.Message = "Err.openCert: ";
throw new Exception(this.Message + e);
catch (SQLException e)
this.Message = "Err.openCert.getCert["+line+"]: ";
throw new Exception(this.Message + e);
catch (Exception e)
this.Message = "Err.openCert.UncaughtException: ";
throw new Exception(this.Message + e);
finally
if(conn != null)
conn.close();





Do you have any idea to how improve the code and refactor it?







share|improve this question













migrated from stackoverflow.com May 15 at 20:58


This question came from our site for professional and enthusiast programmers.














  • There is no key pair here, ergo no keystore either, only a truststore. You aren't checking the value of resultSet.next(). Off topic.
    – user207421
    May 14 at 16:34










  • What is a Conexion?
    – 200_success
    May 15 at 22:38










  • Conexión is a class that extends Connection and do more things, works like Connetion class and take DB connection from a .properties.
    – Rancio
    May 16 at 5:45










  • I don't get what the use of the HostnameVerifier empty if statement is..Seems broken code?
    – RobAu
    May 17 at 8:30












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've a method that gets certificate as BLOB and password as char from Oracle Database, store this certificate x509, trust it, get the secure connection and verify Hostname.



This is the code:



public void openCert() throws Exception CertificateException e) 
this.Message = "Err.openCert: ";
throw new Exception(this.Message + e);
catch (SQLException e)
this.Message = "Err.openCert.getCert["+line+"]: ";
throw new Exception(this.Message + e);
catch (Exception e)
this.Message = "Err.openCert.UncaughtException: ";
throw new Exception(this.Message + e);
finally
if(conn != null)
conn.close();





Do you have any idea to how improve the code and refactor it?







share|improve this question













I've a method that gets certificate as BLOB and password as char from Oracle Database, store this certificate x509, trust it, get the secure connection and verify Hostname.



This is the code:



public void openCert() throws Exception CertificateException e) 
this.Message = "Err.openCert: ";
throw new Exception(this.Message + e);
catch (SQLException e)
this.Message = "Err.openCert.getCert["+line+"]: ";
throw new Exception(this.Message + e);
catch (Exception e)
this.Message = "Err.openCert.UncaughtException: ";
throw new Exception(this.Message + e);
finally
if(conn != null)
conn.close();





Do you have any idea to how improve the code and refactor it?









share|improve this question












share|improve this question




share|improve this question








edited May 15 at 22:38









200_success

123k14143399




123k14143399









asked May 14 at 16:28









Rancio

1




1




migrated from stackoverflow.com May 15 at 20:58


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com May 15 at 20:58


This question came from our site for professional and enthusiast programmers.













  • There is no key pair here, ergo no keystore either, only a truststore. You aren't checking the value of resultSet.next(). Off topic.
    – user207421
    May 14 at 16:34










  • What is a Conexion?
    – 200_success
    May 15 at 22:38










  • Conexión is a class that extends Connection and do more things, works like Connetion class and take DB connection from a .properties.
    – Rancio
    May 16 at 5:45










  • I don't get what the use of the HostnameVerifier empty if statement is..Seems broken code?
    – RobAu
    May 17 at 8:30
















  • There is no key pair here, ergo no keystore either, only a truststore. You aren't checking the value of resultSet.next(). Off topic.
    – user207421
    May 14 at 16:34










  • What is a Conexion?
    – 200_success
    May 15 at 22:38










  • Conexión is a class that extends Connection and do more things, works like Connetion class and take DB connection from a .properties.
    – Rancio
    May 16 at 5:45










  • I don't get what the use of the HostnameVerifier empty if statement is..Seems broken code?
    – RobAu
    May 17 at 8:30















There is no key pair here, ergo no keystore either, only a truststore. You aren't checking the value of resultSet.next(). Off topic.
– user207421
May 14 at 16:34




There is no key pair here, ergo no keystore either, only a truststore. You aren't checking the value of resultSet.next(). Off topic.
– user207421
May 14 at 16:34












What is a Conexion?
– 200_success
May 15 at 22:38




What is a Conexion?
– 200_success
May 15 at 22:38












Conexión is a class that extends Connection and do more things, works like Connetion class and take DB connection from a .properties.
– Rancio
May 16 at 5:45




Conexión is a class that extends Connection and do more things, works like Connetion class and take DB connection from a .properties.
– Rancio
May 16 at 5:45












I don't get what the use of the HostnameVerifier empty if statement is..Seems broken code?
– RobAu
May 17 at 8:30




I don't get what the use of the HostnameVerifier empty if statement is..Seems broken code?
– RobAu
May 17 at 8:30















active

oldest

votes











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f194494%2fmethod-to-store-x509-certificate-from-database%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f194494%2fmethod-to-store-x509-certificate-from-database%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Chat program with C++ and SFML

Function to Return a JSON Like Objects Using VBA Collections and Arrays

Will my employers contract hold up in court?