Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FIT-Connect-SDK - .NET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - .NET
Commits
9b20f508
Commit
9b20f508
authored
2 years ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Exporting self singed cert
parent
6b60061a
No related branches found
No related tags found
1 merge request
!3
Feature/440 mvp net sdk part 1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
FitConnect/FunctionalBaseClass.cs
+1
-1
1 addition, 1 deletion
FitConnect/FunctionalBaseClass.cs
SenderTest/SenderEncryptionTest.cs
+19
-0
19 additions, 0 deletions
SenderTest/SenderEncryptionTest.cs
with
20 additions
and
1 deletion
FitConnect/FunctionalBaseClass.cs
+
1
−
1
View file @
9b20f508
...
...
@@ -6,7 +6,7 @@ using Microsoft.Extensions.Logging;
namespace
FitConnect
;
public
abstract
class
FunctionalBaseClass
:
EncryptionBaseClass
{
public
class
FunctionalBaseClass
:
EncryptionBaseClass
{
protected
readonly
ILogger
?
logger
;
public
FitConnectEndpoints
Endpoints
{
get
;
}
...
...
This diff is collapsed.
Click to expand it.
SenderTest/SenderEncryptionTest.cs
+
19
−
0
View file @
9b20f508
using
System
;
using
System.Buffers.Text
;
using
System.IO
;
using
System.Security.Cryptography
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Text
;
using
FitConnect
;
using
FluentAssertions
;
...
...
@@ -21,6 +23,23 @@ public class SenderEncryptionTest {
FitConnectEndpoints
.
Create
(
FitConnectEndpoints
.
EndpointType
.
Development
));
}
private
X509Certificate2
CreateSelfSignedCertificate
()
{
var
req
=
new
CertificateRequest
(
"cn=foobar"
,
ECDsa
.
Create
(),
HashAlgorithmName
.
SHA256
);
var
cert
=
req
.
CreateSelfSigned
(
DateTimeOffset
.
Now
,
DateTimeOffset
.
Now
.
AddYears
(
5
));
// Create PFX (PKCS #12) with private key
File
.
WriteAllBytes
(
"../../../mycert.pfx"
,
cert
.
Export
(
X509ContentType
.
Pfx
,
"P@55w0rd"
));
// Create Base 64 encoded CER (public key only)
File
.
WriteAllText
(
"../../../mycert.cer"
,
"-----BEGIN CERTIFICATE-----\r\n"
+
Convert
.
ToBase64String
(
cert
.
Export
(
X509ContentType
.
Cert
),
Base64FormattingOptions
.
InsertLineBreaks
)
+
"\r\n-----END CERTIFICATE-----"
);
return
cert
;
}
[
Test
]
public
void
CryptWithPublicKeyImport
()
{
var
publicKey
=
Convert
.
FromBase64String
(
...
...
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