Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
377017f9
Commit
377017f9
authored
Aug 17, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename cleanup
parent
042a3a06
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
39 deletions
+37
-39
WinCertificateMaker.cs
...nium.Web.Proxy/Network/Certificate/WinCertificateMaker.cs
+34
-36
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+2
-2
ResponseHandler.cs
Titanium.Web.Proxy/ResponseHandler.cs
+1
-1
No files found.
Titanium.Web.Proxy/Network/Certificate/WinCertificateMaker.cs
View file @
377017f9
...
...
@@ -74,13 +74,41 @@ namespace Titanium.Web.Proxy.Network.Certificate
/// <summary>
/// Make certificate.
/// </summary>
/// <param name="sSubjectCN"></param>
/// <param name="isRoot"></param>
/// <param name="signingCert"></param>
/// <returns></returns>
public
X509Certificate2
MakeCertificate
(
string
sSubjectCN
,
bool
isRoot
,
X509Certificate2
signingCert
=
null
)
{
return
makeCertificateInternal
(
sSubjectCN
,
isRoot
,
true
,
signingCert
);
return
makeCertificate
(
sSubjectCN
,
isRoot
,
true
,
signingCert
);
}
private
X509Certificate2
makeCertificate
(
string
sSubjectCN
,
bool
isRoot
,
bool
switchToMTAIfNeeded
,
X509Certificate2
signingCert
=
null
,
CancellationToken
cancellationToken
=
default
)
{
if
(
switchToMTAIfNeeded
&&
Thread
.
CurrentThread
.
GetApartmentState
()
!=
ApartmentState
.
MTA
)
{
return
Task
.
Run
(()
=>
makeCertificate
(
sSubjectCN
,
isRoot
,
false
,
signingCert
),
cancellationToken
).
Result
;
}
// Subject
string
fullSubject
=
$"CN=
{
sSubjectCN
}
"
;
// Sig Algo
const
string
hashAlgo
=
"SHA256"
;
// Grace Days
const
int
graceDays
=
-
366
;
// ValiDays
const
int
validDays
=
1825
;
// KeyLength
const
int
keyLength
=
2048
;
var
graceTime
=
DateTime
.
Now
.
AddDays
(
graceDays
);
var
now
=
DateTime
.
Now
;
var
certificate
=
makeCertificate
(
isRoot
,
sSubjectCN
,
fullSubject
,
keyLength
,
hashAlgo
,
graceTime
,
now
.
AddDays
(
validDays
),
isRoot
?
null
:
signingCert
);
return
certificate
;
}
private
X509Certificate2
makeCertificate
(
bool
isRoot
,
string
subject
,
string
fullSubject
,
...
...
@@ -271,39 +299,9 @@ namespace Titanium.Web.Proxy.Network.Certificate
string
empty
=
(
string
)
typeX509Enrollment
.
InvokeMember
(
"CreatePFX"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
return
new
X509Certificate2
(
Convert
.
FromBase64String
(
empty
),
string
.
Empty
,
X509KeyStorageFlags
.
Exportable
);
}
private
X509Certificate2
makeCertificateInternal
(
string
sSubjectCN
,
bool
isRoot
,
bool
switchToMTAIfNeeded
,
X509Certificate2
signingCert
=
null
,
CancellationToken
cancellationToken
=
default
)
{
if
(
switchToMTAIfNeeded
&&
Thread
.
CurrentThread
.
GetApartmentState
()
!=
ApartmentState
.
MTA
)
{
return
Task
.
Run
(()
=>
makeCertificateInternal
(
sSubjectCN
,
isRoot
,
false
,
signingCert
),
cancellationToken
).
Result
;
}
// Subject
string
fullSubject
=
$"CN=
{
sSubjectCN
}
"
;
// Sig Algo
const
string
hashAlgo
=
"SHA256"
;
// Grace Days
const
int
graceDays
=
-
366
;
// ValiDays
const
int
validDays
=
1825
;
// KeyLength
const
int
keyLength
=
2048
;
var
graceTime
=
DateTime
.
Now
.
AddDays
(
graceDays
);
var
now
=
DateTime
.
Now
;
var
certificate
=
makeCertificate
(
isRoot
,
sSubjectCN
,
fullSubject
,
keyLength
,
hashAlgo
,
graceTime
,
now
.
AddDays
(
validDays
),
isRoot
?
null
:
signingCert
);
return
certificate
;
}
}
}
Titanium.Web.Proxy/RequestHandler.cs
View file @
377017f9
...
...
@@ -228,7 +228,7 @@ namespace Titanium.Web.Proxy
}
// construct the web request that we are going to issue on behalf of the client.
await
handleHttpSessionRequest
Internal
(
serverConnection
,
args
);
await
handleHttpSessionRequest
(
serverConnection
,
args
);
return
true
;
},
generator
,
connection
);
...
...
@@ -312,7 +312,7 @@ namespace Titanium.Web.Proxy
/// <param name="serverConnection">The tcp connection.</param>
/// <param name="args">The session event arguments.</param>
/// <returns></returns>
private
async
Task
handleHttpSessionRequest
Internal
(
TcpServerConnection
serverConnection
,
SessionEventArgs
args
)
private
async
Task
handleHttpSessionRequest
(
TcpServerConnection
serverConnection
,
SessionEventArgs
args
)
{
var
cancellationToken
=
args
.
CancellationTokenSource
.
Token
;
var
request
=
args
.
WebSession
.
Request
;
...
...
Titanium.Web.Proxy/ResponseHandler.cs
View file @
377017f9
...
...
@@ -80,7 +80,7 @@ namespace Titanium.Web.Proxy
{
// clear current response
await
args
.
ClearResponse
(
cancellationToken
);
await
handleHttpSessionRequest
Internal
(
args
.
WebSession
.
ServerConnection
,
args
);
await
handleHttpSessionRequest
(
args
.
WebSession
.
ServerConnection
,
args
);
return
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment