Add OpenSslLegacyShim to ensure OpenSSL 1.1 libraries are accessible on Linux
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Docs CI / lint-and-preview (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Docs CI / lint-and-preview (push) Has been cancelled
				
			This commit introduces the OpenSslLegacyShim class, which sets the LD_LIBRARY_PATH environment variable to include the directory containing OpenSSL 1.1 native libraries. This is necessary for Mongo2Go to function correctly on Linux platforms that do not ship these libraries by default. The shim checks if the current operating system is Linux and whether the required directory exists before modifying the environment variable.
This commit is contained in:
		
							
								
								
									
										7
									
								
								tests/native/openssl-1.1/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								tests/native/openssl-1.1/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
# OpenSSL 1.1 Test Shim
 | 
			
		||||
 | 
			
		||||
These binaries (libcrypto.so.1.1 and libssl.so.1.1) are bundled for Mongo2Go-based integration tests so they can run on hosts that only provide OpenSSL 3.
 | 
			
		||||
 | 
			
		||||
Source package: https://launchpad.net/ubuntu/+archive/primary/+files/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
 | 
			
		||||
 | 
			
		||||
Licensing follows the OpenSSL and SSLeay licenses that accompany the upstream package.
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								tests/native/openssl-1.1/linux-x64/libcrypto.so.1.1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								tests/native/openssl-1.1/linux-x64/libcrypto.so.1.1
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								tests/native/openssl-1.1/linux-x64/libssl.so.1.1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								tests/native/openssl-1.1/linux-x64/libssl.so.1.1
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										43
									
								
								tests/shared/OpenSslLegacyShim.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								tests/shared/OpenSslLegacyShim.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
 | 
			
		||||
namespace StellaOps.Testing;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Ensures OpenSSL 1.1 native libraries are visible to Mongo2Go on platforms that no longer ship them.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class OpenSslLegacyShim
 | 
			
		||||
{
 | 
			
		||||
    private const string LinuxLibraryVariable = "LD_LIBRARY_PATH";
 | 
			
		||||
 | 
			
		||||
    public static void EnsureOpenSsl11()
 | 
			
		||||
    {
 | 
			
		||||
        if (!OperatingSystem.IsLinux())
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var nativeDirectory = Path.Combine(AppContext.BaseDirectory, "native", "linux-x64");
 | 
			
		||||
        if (!Directory.Exists(nativeDirectory))
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var current = Environment.GetEnvironmentVariable(LinuxLibraryVariable);
 | 
			
		||||
        if (string.IsNullOrEmpty(current))
 | 
			
		||||
        {
 | 
			
		||||
            Environment.SetEnvironmentVariable(LinuxLibraryVariable, nativeDirectory);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const char separator = ':';
 | 
			
		||||
        var segments = current.Split(separator, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
 | 
			
		||||
        if (segments.Contains(nativeDirectory, StringComparer.Ordinal))
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Environment.SetEnvironmentVariable(LinuxLibraryVariable, string.Concat(nativeDirectory, separator, current));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user