Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Lowden
OpenLDAP
Commits
177ec8d8
Commit
177ec8d8
authored
12 years ago
by
Ralf Haferkamp
Committed by
Quanah Gibson-Mount
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add some simple checks for certificate directories/files
parent
a25d8ccc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/ldapc++/src/TlsOptions.cpp
+42
-0
42 additions, 0 deletions
contrib/ldapc++/src/TlsOptions.cpp
with
42 additions
and
0 deletions
contrib/ldapc++/src/TlsOptions.cpp
+
42
−
0
View file @
177ec8d8
...
...
@@ -4,6 +4,13 @@
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include
<fstream>
#include
<sstream>
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<errno.h>
#include
<unistd.h>
#include
<cstring>
#include
"TlsOptions.h"
#include
"LDAPException.h"
...
...
@@ -54,6 +61,41 @@ TlsOptions::TlsOptions( LDAP* ld ): m_ld(ld) { }
void
TlsOptions
::
setOption
(
tls_option
opt
,
const
std
::
string
&
value
)
const
{
checkOpt
(
opt
,
STRING
);
switch
(
opt
)
{
case
TlsOptions
::
CACERTFILE
:
case
TlsOptions
::
CERTFILE
:
case
TlsOptions
::
KEYFILE
:
{
// check if the supplied file is actually readable
std
::
ifstream
ifile
(
value
.
c_str
());
if
(
!
ifile
)
{
throw
(
LDAPException
(
LDAP_LOCAL_ERROR
,
"Unable to open the supplied file for reading"
)
);
}
}
break
;
case
TlsOptions
::
CACERTDIR
:
{
struct
stat
st
;
std
::
ostringstream
msg
;
bool
fail
=
false
;
int
err
=
stat
(
value
.
c_str
(),
&
st
);
if
(
err
)
{
msg
<<
strerror
(
errno
);
fail
=
true
;
}
else
{
if
(
!
S_ISDIR
(
st
.
st_mode
)
){
msg
<<
"The supplied path is not a directory."
;
fail
=
true
;
}
}
if
(
fail
)
{
std
::
ostringstream
errstr
;
errstr
<<
"Error while setting Certificate Directory ("
<<
value
<<
"): "
<<
msg
.
str
();
throw
(
LDAPException
(
LDAP_LOCAL_ERROR
,
errstr
.
str
()
)
);
}
}
break
;
}
this
->
setOption
(
opt
,
value
.
empty
()
?
NULL
:
(
void
*
)
value
.
c_str
()
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment