Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-plugins-store
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
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
savoirfairelinux
jami-plugins-store
Commits
f3604f05
Commit
f3604f05
authored
1 year ago
by
Xavier Jouslin de Noray
Browse files
Options
Downloads
Patches
Plain Diff
CRL: make accessible the crl for root and sfl
Gitlab:
#12
Change-Id: If9e93db6adba0a9fda26e07e417cbb3144eed05c
parent
52c6b351
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/certificate.manager.service.ts
+31
-20
31 additions, 20 deletions
src/services/certificate.manager.service.ts
tests/certificate.manager.test.ts
+3
-3
3 additions, 3 deletions
tests/certificate.manager.test.ts
with
34 additions
and
23 deletions
src/services/certificate.manager.service.ts
+
31
−
20
View file @
f3604f05
...
...
@@ -29,37 +29,48 @@ export class CertificateManager {
}
async
getCaCrlPath
():
Promise
<
string
>
{
const
crlFilePath
=
(
process
.
env
.
DATA_DIRECTORY
as
string
)
+
'
/
'
+
'
root.crl
'
;
const
isCRLFileExist
=
await
this
.
fileManager
.
isFileExist
(
crlFilePath
);
if
(
process
.
env
.
DATA_DIRECTORY
===
undefined
||
!
isCRLFileExist
)
{
return
''
;
}
return
crlFilePath
;
return
await
this
.
getCrlPath
(
// eslint-disable-next-line
__dirname
+
'
/../..
'
+
(
process
.
env
.
DATA_DIRECTORY
as
string
),
'
root.crl
'
);
}
async
getSflCrlPath
():
Promise
<
string
>
{
const
crlFilePath
=
(
process
.
env
.
DATA_DIRECTORY
as
string
)
+
'
/
'
+
'
SFL.crl
'
;
const
isCRLFileExist
=
await
this
.
fileManager
.
isFileExist
(
crlFilePath
);
if
(
process
.
env
.
DATA_DIRECTORY
===
undefined
||
!
isCRLFileExist
)
{
return
await
this
.
getCrlPath
(
// eslint-disable-next-line
__dirname
+
'
/../..
'
+
(
process
.
env
.
DATA_DIRECTORY
as
string
),
'
SFL.crl
'
);
}
async
getCrlPath
(
path
:
string
,
file
:
string
):
Promise
<
string
>
{
const
crlPath
=
path
+
'
/
'
+
file
;
const
isCrlFileExist
=
await
this
.
fileManager
.
isFileExist
(
crlPath
);
if
(
process
.
env
.
DATA_DIRECTORY
===
undefined
||
!
isCrlFileExist
)
{
return
''
;
}
return
crl
File
Path
;
return
crlPath
;
}
async
getCaCrl
():
Promise
<
string
>
{
async
getCaCrl
():
Promise
<
Buffer
>
{
if
(
process
.
env
.
DATA_DIRECTORY
===
undefined
)
{
return
''
;
return
Buffer
.
from
(
''
)
;
}
return
await
this
.
readCRL
(
process
.
env
.
DATA_DIRECTORY
+
'
/
'
+
'
ca.crl
'
);
return
await
this
.
readCRL
(
// eslint-disable-next-line
__dirname
+
'
/../..
'
+
process
.
env
.
DATA_DIRECTORY
+
'
/
'
+
'
root.crl
'
);
}
async
getSflCrl
():
Promise
<
string
>
{
async
getSflCrl
():
Promise
<
Buffer
>
{
if
(
process
.
env
.
DATA_DIRECTORY
===
undefined
)
{
return
''
;
return
Buffer
.
from
(
''
)
;
}
return
await
this
.
readCRL
(
process
.
env
.
DATA_DIRECTORY
+
'
/
'
+
'
sfl.crl
'
);
return
await
this
.
readCRL
(
// eslint-disable-next-line
__dirname
+
'
/../..
'
+
process
.
env
.
DATA_DIRECTORY
+
'
/
'
+
'
sfl.crl
'
);
}
verifySignature
(
signature
:
Buffer
,
checkSignature
:
Buffer
):
boolean
{
...
...
@@ -74,8 +85,8 @@ export class CertificateManager {
});
}
private
async
readCRL
(
file
:
string
):
Promise
<
string
>
{
return
(
await
this
.
fileManager
.
readFile
(
file
)
).
toString
()
;
private
async
readCRL
(
file
:
string
):
Promise
<
Buffer
>
{
return
await
this
.
fileManager
.
readFile
(
file
);
}
parseDN
(
dn
:
string
):
Record
<
string
,
string
>
{
...
...
This diff is collapsed.
Click to expand it.
tests/certificate.manager.test.ts
+
3
−
3
View file @
f3604f05
...
...
@@ -70,21 +70,21 @@ describe('Certificate manager service tests', function () {
const
expectedCRL
=
'
test
'
;
fileManager
.
readFile
.
resolves
(
Buffer
.
from
(
expectedCRL
,
'
utf-8
'
));
const
crl
=
await
certificateManager
[
'
readCRL
'
](
path
+
'
/
'
+
file
);
expect
(
crl
).
toEqual
(
expectedCRL
);
expect
(
crl
).
toEqual
(
Buffer
.
from
(
expectedCRL
,
'
utf-8
'
)
);
});
it
(
'
should return sfl crl
'
,
async
()
=>
{
const
expectedCRL
=
'
test
'
;
fileManager
.
readFile
.
resolves
(
Buffer
.
from
(
expectedCRL
,
'
utf-8
'
));
const
crl
=
await
certificateManager
.
getSflCrl
();
expect
(
crl
).
toEqual
(
expectedCRL
);
expect
(
crl
).
toEqual
(
Buffer
.
from
(
expectedCRL
,
'
utf-8
'
)
);
});
it
(
'
should return ca crl
'
,
async
()
=>
{
const
expectedCRL
=
'
test
'
;
fileManager
.
readFile
.
resolves
(
Buffer
.
from
(
expectedCRL
,
'
utf-8
'
));
const
crl
=
await
certificateManager
.
getCaCrl
();
expect
(
crl
).
toEqual
(
expectedCRL
);
expect
(
crl
).
toEqual
(
Buffer
.
from
(
expectedCRL
,
'
utf-8
'
)
);
});
it
(
'
should parse the DN correctly
'
,
()
=>
{
const
dn
=
'
CN=John Doe
\n
O=Acme Corp
'
;
...
...
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